diff --git a/UnitsNet.Tests/GeneratedCode/.gitignore b/UnitsNet.Tests/GeneratedCode/.gitignore
new file mode 100644
index 0000000000..6dd350f428
--- /dev/null
+++ b/UnitsNet.Tests/GeneratedCode/.gitignore
@@ -0,0 +1,4 @@
+*.g.cs
+!InformationTestsBase.g.cs
+!LengthTestsBase.g.cs
+!LevelTestsBase.g.cs
diff --git a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
deleted file mode 100644
index a2265bb678..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AccelerationTestsBase.g.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 Acceleration.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AccelerationTestsBase
- {
- protected abstract double CentimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double DecimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double FeetPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double InchesPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double KilometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerHourInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerMinuteInOneMeterPerSecondSquared { get; }
- protected abstract double KnotsPerSecondInOneMeterPerSecondSquared { get; }
- protected abstract double MetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double MicrometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double MillimetersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double NanometersPerSecondSquaredInOneMeterPerSecondSquared { get; }
- protected abstract double StandardGravityInOneMeterPerSecondSquared { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double FeetPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double InchesPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double KilometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerHourTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerMinuteTolerance { get { return 1e-5; } }
- protected virtual double KnotsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double NanometersPerSecondSquaredTolerance { get { return 1e-5; } }
- protected virtual double StandardGravityTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new Acceleration((double)0.0, AccelerationUnit.Undefined));
- }
-
- [Fact]
- public void Ctor_WithInfinityValue_ThrowsArgumentException()
- {
- 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));
- }
-
- [Fact]
- public void MeterPerSecondSquaredToAccelerationUnits()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.FeetPerSecondSquared, FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.InchesPerSecondSquared, InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.KilometersPerSecondSquared, KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerHour, KnotsPerHourTolerance);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerMinute, KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, meterpersecondsquared.KnotsPerSecond, KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MicrometersPerSecondSquared, MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.MillimetersPerSecondSquared, MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.NanometersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, meterpersecondsquared.StandardGravity, StandardGravityTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.CentimeterPerSecondSquared).CentimetersPerSecondSquared, CentimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.DecimeterPerSecondSquared).DecimetersPerSecondSquared, DecimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.FootPerSecondSquared).FeetPerSecondSquared, FeetPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.InchPerSecondSquared).InchesPerSecondSquared, InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KilometerPerSecondSquared).KilometersPerSecondSquared, KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerHour).KnotsPerHour, KnotsPerHourTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerMinute).KnotsPerMinute, KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.KnotPerSecond).KnotsPerSecond, KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MeterPerSecondSquared).MetersPerSecondSquared, MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MicrometerPerSecondSquared).MicrometersPerSecondSquared, MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.MillimeterPerSecondSquared).MillimetersPerSecondSquared, MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.NanometerPerSecondSquared).NanometersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.From(1, AccelerationUnit.StandardGravity).StandardGravity, StandardGravityTolerance);
- }
-
- [Fact]
- public void FromMetersPerSecondSquared_WithInfinityValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.PositiveInfinity));
- Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NegativeInfinity));
- }
-
- [Fact]
- public void FromMetersPerSecondSquared_WithNanValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Acceleration.FromMetersPerSecondSquared(double.NaN));
- }
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.InchPerSecondSquared), InchesPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KilometerPerSecondSquared), KilometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerHour), KnotsPerHourTolerance);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerMinute), KnotsPerMinuteTolerance);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.KnotPerSecond), KnotsPerSecondTolerance);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MeterPerSecondSquared), MetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MicrometerPerSecondSquared), MicrometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.MillimeterPerSecondSquared), MillimetersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.NanometerPerSecondSquared), NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, meterpersecondsquared.As(AccelerationUnit.StandardGravity), StandardGravityTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
-
- var centimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.CentimeterPerSecondSquared);
- AssertEx.EqualTolerance(CentimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)centimeterpersecondsquaredQuantity.Value, CentimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.CentimeterPerSecondSquared, centimeterpersecondsquaredQuantity.Unit);
-
- var decimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.DecimeterPerSecondSquared);
- AssertEx.EqualTolerance(DecimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)decimeterpersecondsquaredQuantity.Value, DecimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.DecimeterPerSecondSquared, decimeterpersecondsquaredQuantity.Unit);
-
- var footpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.FootPerSecondSquared);
- AssertEx.EqualTolerance(FeetPerSecondSquaredInOneMeterPerSecondSquared, (double)footpersecondsquaredQuantity.Value, FeetPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.FootPerSecondSquared, footpersecondsquaredQuantity.Unit);
-
- var inchpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.InchPerSecondSquared);
- AssertEx.EqualTolerance(InchesPerSecondSquaredInOneMeterPerSecondSquared, (double)inchpersecondsquaredQuantity.Value, InchesPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.InchPerSecondSquared, inchpersecondsquaredQuantity.Unit);
-
- var kilometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KilometerPerSecondSquared);
- AssertEx.EqualTolerance(KilometersPerSecondSquaredInOneMeterPerSecondSquared, (double)kilometerpersecondsquaredQuantity.Value, KilometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.KilometerPerSecondSquared, kilometerpersecondsquaredQuantity.Unit);
-
- var knotperhourQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerHour);
- AssertEx.EqualTolerance(KnotsPerHourInOneMeterPerSecondSquared, (double)knotperhourQuantity.Value, KnotsPerHourTolerance);
- Assert.Equal(AccelerationUnit.KnotPerHour, knotperhourQuantity.Unit);
-
- var knotperminuteQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerMinute);
- AssertEx.EqualTolerance(KnotsPerMinuteInOneMeterPerSecondSquared, (double)knotperminuteQuantity.Value, KnotsPerMinuteTolerance);
- Assert.Equal(AccelerationUnit.KnotPerMinute, knotperminuteQuantity.Unit);
-
- var knotpersecondQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.KnotPerSecond);
- AssertEx.EqualTolerance(KnotsPerSecondInOneMeterPerSecondSquared, (double)knotpersecondQuantity.Value, KnotsPerSecondTolerance);
- Assert.Equal(AccelerationUnit.KnotPerSecond, knotpersecondQuantity.Unit);
-
- var meterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MeterPerSecondSquared);
- AssertEx.EqualTolerance(MetersPerSecondSquaredInOneMeterPerSecondSquared, (double)meterpersecondsquaredQuantity.Value, MetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MeterPerSecondSquared, meterpersecondsquaredQuantity.Unit);
-
- var micrometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MicrometerPerSecondSquared);
- AssertEx.EqualTolerance(MicrometersPerSecondSquaredInOneMeterPerSecondSquared, (double)micrometerpersecondsquaredQuantity.Value, MicrometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MicrometerPerSecondSquared, micrometerpersecondsquaredQuantity.Unit);
-
- var millimeterpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.MillimeterPerSecondSquared);
- AssertEx.EqualTolerance(MillimetersPerSecondSquaredInOneMeterPerSecondSquared, (double)millimeterpersecondsquaredQuantity.Value, MillimetersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.MillimeterPerSecondSquared, millimeterpersecondsquaredQuantity.Unit);
-
- var nanometerpersecondsquaredQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.NanometerPerSecondSquared);
- AssertEx.EqualTolerance(NanometersPerSecondSquaredInOneMeterPerSecondSquared, (double)nanometerpersecondsquaredQuantity.Value, NanometersPerSecondSquaredTolerance);
- Assert.Equal(AccelerationUnit.NanometerPerSecondSquared, nanometerpersecondsquaredQuantity.Unit);
-
- var standardgravityQuantity = meterpersecondsquared.ToUnit(AccelerationUnit.StandardGravity);
- AssertEx.EqualTolerance(StandardGravityInOneMeterPerSecondSquared, (double)standardgravityQuantity.Value, StandardGravityTolerance);
- Assert.Equal(AccelerationUnit.StandardGravity, standardgravityQuantity.Unit);
- }
-
- [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.FromNanometersPerSecondSquared(meterpersecondsquared.NanometersPerSecondSquared).MetersPerSecondSquared, NanometersPerSecondSquaredTolerance);
- AssertEx.EqualTolerance(1, Acceleration.FromStandardGravity(meterpersecondsquared.StandardGravity).MetersPerSecondSquared, StandardGravityTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Acceleration v = Acceleration.FromMetersPerSecondSquared(1);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Acceleration oneMeterPerSecondSquared = Acceleration.FromMetersPerSecondSquared(1);
- Acceleration twoMetersPerSecondSquared = Acceleration.FromMetersPerSecondSquared(2);
-
- Assert.True(oneMeterPerSecondSquared < twoMetersPerSecondSquared);
- Assert.True(oneMeterPerSecondSquared <= twoMetersPerSecondSquared);
- Assert.True(twoMetersPerSecondSquared > oneMeterPerSecondSquared);
- Assert.True(twoMetersPerSecondSquared >= oneMeterPerSecondSquared);
-
- Assert.False(oneMeterPerSecondSquared > twoMetersPerSecondSquared);
- Assert.False(oneMeterPerSecondSquared >= twoMetersPerSecondSquared);
- Assert.False(twoMetersPerSecondSquared < oneMeterPerSecondSquared);
- Assert.False(twoMetersPerSecondSquared <= oneMeterPerSecondSquared);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Throws(() => meterpersecondsquared.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.Throws(() => meterpersecondsquared.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- Acceleration v = Acceleration.FromMetersPerSecondSquared(1);
- Assert.True(v.Equals(Acceleration.FromMetersPerSecondSquared(1), MetersPerSecondSquaredTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(Acceleration.Zero, MetersPerSecondSquaredTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.False(meterpersecondsquared.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Acceleration meterpersecondsquared = Acceleration.FromMetersPerSecondSquared(1);
- Assert.False(meterpersecondsquared.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AccelerationUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AccelerationUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
deleted file mode 100644
index e72fb73a08..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AmountOfSubstanceTestsBase.g.cs
+++ /dev/null
@@ -1,354 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 AmountOfSubstance.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AmountOfSubstanceTestsBase
- {
- protected abstract double CentimolesInOneMole { get; }
- protected abstract double CentipoundMolesInOneMole { get; }
- protected abstract double DecimolesInOneMole { get; }
- protected abstract double DecipoundMolesInOneMole { get; }
- protected abstract double KilomolesInOneMole { get; }
- protected abstract double KilopoundMolesInOneMole { get; }
- protected abstract double MicromolesInOneMole { get; }
- protected abstract double MicropoundMolesInOneMole { get; }
- protected abstract double MillimolesInOneMole { get; }
- protected abstract double MillipoundMolesInOneMole { get; }
- protected abstract double MolesInOneMole { get; }
- protected abstract double NanomolesInOneMole { get; }
- protected abstract double NanopoundMolesInOneMole { get; }
- protected abstract double PoundMolesInOneMole { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentimolesTolerance { get { return 1e-5; } }
- protected virtual double CentipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double DecimolesTolerance { get { return 1e-5; } }
- protected virtual double DecipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double KilomolesTolerance { get { return 1e-5; } }
- protected virtual double KilopoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MicromolesTolerance { get { return 1e-5; } }
- protected virtual double MicropoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MillimolesTolerance { get { return 1e-5; } }
- protected virtual double MillipoundMolesTolerance { get { return 1e-5; } }
- protected virtual double MolesTolerance { get { return 1e-5; } }
- protected virtual double NanomolesTolerance { get { return 1e-5; } }
- protected virtual double NanopoundMolesTolerance { get { return 1e-5; } }
- protected virtual double PoundMolesTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new AmountOfSubstance((double)0.0, AmountOfSubstanceUnit.Undefined));
- }
-
- [Fact]
- public void Ctor_WithInfinityValue_ThrowsArgumentException()
- {
- 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));
- }
-
- [Fact]
- public void MoleToAmountOfSubstanceUnits()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- AssertEx.EqualTolerance(CentimolesInOneMole, mole.Centimoles, CentimolesTolerance);
- AssertEx.EqualTolerance(CentipoundMolesInOneMole, mole.CentipoundMoles, CentipoundMolesTolerance);
- AssertEx.EqualTolerance(DecimolesInOneMole, mole.Decimoles, DecimolesTolerance);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.DecipoundMoles, DecipoundMolesTolerance);
- AssertEx.EqualTolerance(KilomolesInOneMole, mole.Kilomoles, KilomolesTolerance);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.KilopoundMoles, KilopoundMolesTolerance);
- AssertEx.EqualTolerance(MicromolesInOneMole, mole.Micromoles, MicromolesTolerance);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.MicropoundMoles, MicropoundMolesTolerance);
- AssertEx.EqualTolerance(MillimolesInOneMole, mole.Millimoles, MillimolesTolerance);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.MillipoundMoles, MillipoundMolesTolerance);
- AssertEx.EqualTolerance(MolesInOneMole, mole.Moles, MolesTolerance);
- AssertEx.EqualTolerance(NanomolesInOneMole, mole.Nanomoles, NanomolesTolerance);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.NanopoundMoles, NanopoundMolesTolerance);
- AssertEx.EqualTolerance(PoundMolesInOneMole, mole.PoundMoles, PoundMolesTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Centimole).Centimoles, CentimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.CentipoundMole).CentipoundMoles, CentipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Decimole).Decimoles, DecimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.DecipoundMole).DecipoundMoles, DecipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Kilomole).Kilomoles, KilomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.KilopoundMole).KilopoundMoles, KilopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Micromole).Micromoles, MicromolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MicropoundMole).MicropoundMoles, MicropoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Millimole).Millimoles, MillimolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.MillipoundMole).MillipoundMoles, MillipoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Mole).Moles, MolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.Nanomole).Nanomoles, NanomolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.NanopoundMole).NanopoundMoles, NanopoundMolesTolerance);
- AssertEx.EqualTolerance(1, AmountOfSubstance.From(1, AmountOfSubstanceUnit.PoundMole).PoundMoles, PoundMolesTolerance);
- }
-
- [Fact]
- public void FromMoles_WithInfinityValue_ThrowsArgumentException()
- {
- Assert.Throws(() => AmountOfSubstance.FromMoles(double.PositiveInfinity));
- Assert.Throws(() => AmountOfSubstance.FromMoles(double.NegativeInfinity));
- }
-
- [Fact]
- public void FromMoles_WithNanValue_ThrowsArgumentException()
- {
- Assert.Throws(() => AmountOfSubstance.FromMoles(double.NaN));
- }
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.DecipoundMole), DecipoundMolesTolerance);
- AssertEx.EqualTolerance(KilomolesInOneMole, mole.As(AmountOfSubstanceUnit.Kilomole), KilomolesTolerance);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.KilopoundMole), KilopoundMolesTolerance);
- AssertEx.EqualTolerance(MicromolesInOneMole, mole.As(AmountOfSubstanceUnit.Micromole), MicromolesTolerance);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MicropoundMole), MicropoundMolesTolerance);
- AssertEx.EqualTolerance(MillimolesInOneMole, mole.As(AmountOfSubstanceUnit.Millimole), MillimolesTolerance);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.MillipoundMole), MillipoundMolesTolerance);
- AssertEx.EqualTolerance(MolesInOneMole, mole.As(AmountOfSubstanceUnit.Mole), MolesTolerance);
- AssertEx.EqualTolerance(NanomolesInOneMole, mole.As(AmountOfSubstanceUnit.Nanomole), NanomolesTolerance);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.NanopoundMole), NanopoundMolesTolerance);
- AssertEx.EqualTolerance(PoundMolesInOneMole, mole.As(AmountOfSubstanceUnit.PoundMole), PoundMolesTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var mole = AmountOfSubstance.FromMoles(1);
-
- var centimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Centimole);
- AssertEx.EqualTolerance(CentimolesInOneMole, (double)centimoleQuantity.Value, CentimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Centimole, centimoleQuantity.Unit);
-
- var centipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.CentipoundMole);
- AssertEx.EqualTolerance(CentipoundMolesInOneMole, (double)centipoundmoleQuantity.Value, CentipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.CentipoundMole, centipoundmoleQuantity.Unit);
-
- var decimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Decimole);
- AssertEx.EqualTolerance(DecimolesInOneMole, (double)decimoleQuantity.Value, DecimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Decimole, decimoleQuantity.Unit);
-
- var decipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.DecipoundMole);
- AssertEx.EqualTolerance(DecipoundMolesInOneMole, (double)decipoundmoleQuantity.Value, DecipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.DecipoundMole, decipoundmoleQuantity.Unit);
-
- var kilomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Kilomole);
- AssertEx.EqualTolerance(KilomolesInOneMole, (double)kilomoleQuantity.Value, KilomolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Kilomole, kilomoleQuantity.Unit);
-
- var kilopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.KilopoundMole);
- AssertEx.EqualTolerance(KilopoundMolesInOneMole, (double)kilopoundmoleQuantity.Value, KilopoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.KilopoundMole, kilopoundmoleQuantity.Unit);
-
- var micromoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Micromole);
- AssertEx.EqualTolerance(MicromolesInOneMole, (double)micromoleQuantity.Value, MicromolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Micromole, micromoleQuantity.Unit);
-
- var micropoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MicropoundMole);
- AssertEx.EqualTolerance(MicropoundMolesInOneMole, (double)micropoundmoleQuantity.Value, MicropoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.MicropoundMole, micropoundmoleQuantity.Unit);
-
- var millimoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Millimole);
- AssertEx.EqualTolerance(MillimolesInOneMole, (double)millimoleQuantity.Value, MillimolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Millimole, millimoleQuantity.Unit);
-
- var millipoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.MillipoundMole);
- AssertEx.EqualTolerance(MillipoundMolesInOneMole, (double)millipoundmoleQuantity.Value, MillipoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.MillipoundMole, millipoundmoleQuantity.Unit);
-
- var moleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Mole);
- AssertEx.EqualTolerance(MolesInOneMole, (double)moleQuantity.Value, MolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Mole, moleQuantity.Unit);
-
- var nanomoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.Nanomole);
- AssertEx.EqualTolerance(NanomolesInOneMole, (double)nanomoleQuantity.Value, NanomolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.Nanomole, nanomoleQuantity.Unit);
-
- var nanopoundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.NanopoundMole);
- AssertEx.EqualTolerance(NanopoundMolesInOneMole, (double)nanopoundmoleQuantity.Value, NanopoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.NanopoundMole, nanopoundmoleQuantity.Unit);
-
- var poundmoleQuantity = mole.ToUnit(AmountOfSubstanceUnit.PoundMole);
- AssertEx.EqualTolerance(PoundMolesInOneMole, (double)poundmoleQuantity.Value, PoundMolesTolerance);
- Assert.Equal(AmountOfSubstanceUnit.PoundMole, poundmoleQuantity.Unit);
- }
-
- [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.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);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- AmountOfSubstance oneMole = AmountOfSubstance.FromMoles(1);
- AmountOfSubstance twoMoles = AmountOfSubstance.FromMoles(2);
-
- Assert.True(oneMole < twoMoles);
- Assert.True(oneMole <= twoMoles);
- Assert.True(twoMoles > oneMole);
- Assert.True(twoMoles >= oneMole);
-
- Assert.False(oneMole > twoMoles);
- Assert.False(oneMole >= twoMoles);
- Assert.False(twoMoles < oneMole);
- Assert.False(twoMoles <= oneMole);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.Throws(() => mole.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.Throws(() => mole.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- AmountOfSubstance v = AmountOfSubstance.FromMoles(1);
- Assert.True(v.Equals(AmountOfSubstance.FromMoles(1), MolesTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(AmountOfSubstance.Zero, MolesTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.False(mole.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- AmountOfSubstance mole = AmountOfSubstance.FromMoles(1);
- Assert.False(mole.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AmountOfSubstanceUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
deleted file mode 100644
index cfdaee8eca..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AmplitudeRatioTestsBase.g.cs
+++ /dev/null
@@ -1,259 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- AmplitudeRatio 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AmplitudeRatioUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
deleted file mode 100644
index 8ef19e88cc..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AngleTestsBase.g.cs
+++ /dev/null
@@ -1,354 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 Angle.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AngleTestsBase
- {
- protected abstract double ArcminutesInOneDegree { get; }
- protected abstract double ArcsecondsInOneDegree { get; }
- protected abstract double CentiradiansInOneDegree { get; }
- protected abstract double DeciradiansInOneDegree { get; }
- protected abstract double DegreesInOneDegree { get; }
- protected abstract double GradiansInOneDegree { get; }
- protected abstract double MicrodegreesInOneDegree { get; }
- protected abstract double MicroradiansInOneDegree { get; }
- protected abstract double MillidegreesInOneDegree { get; }
- protected abstract double MilliradiansInOneDegree { get; }
- protected abstract double NanodegreesInOneDegree { get; }
- protected abstract double NanoradiansInOneDegree { get; }
- protected abstract double RadiansInOneDegree { get; }
- protected abstract double RevolutionsInOneDegree { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double ArcminutesTolerance { get { return 1e-5; } }
- protected virtual double ArcsecondsTolerance { get { return 1e-5; } }
- protected virtual double CentiradiansTolerance { get { return 1e-5; } }
- protected virtual double DeciradiansTolerance { get { return 1e-5; } }
- protected virtual double DegreesTolerance { get { return 1e-5; } }
- protected virtual double GradiansTolerance { get { return 1e-5; } }
- protected virtual double MicrodegreesTolerance { get { return 1e-5; } }
- protected virtual double MicroradiansTolerance { get { return 1e-5; } }
- protected virtual double MillidegreesTolerance { get { return 1e-5; } }
- protected virtual double MilliradiansTolerance { get { return 1e-5; } }
- protected virtual double NanodegreesTolerance { get { return 1e-5; } }
- protected virtual double NanoradiansTolerance { get { return 1e-5; } }
- protected virtual double RadiansTolerance { get { return 1e-5; } }
- protected virtual double RevolutionsTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new Angle((double)0.0, AngleUnit.Undefined));
- }
-
- [Fact]
- public void Ctor_WithInfinityValue_ThrowsArgumentException()
- {
- 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));
- }
-
- [Fact]
- public void DegreeToAngleUnits()
- {
- Angle degree = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(ArcminutesInOneDegree, degree.Arcminutes, ArcminutesTolerance);
- AssertEx.EqualTolerance(ArcsecondsInOneDegree, degree.Arcseconds, ArcsecondsTolerance);
- AssertEx.EqualTolerance(CentiradiansInOneDegree, degree.Centiradians, CentiradiansTolerance);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, degree.Deciradians, DeciradiansTolerance);
- AssertEx.EqualTolerance(DegreesInOneDegree, degree.Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(GradiansInOneDegree, degree.Gradians, GradiansTolerance);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, degree.Microdegrees, MicrodegreesTolerance);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, degree.Microradians, MicroradiansTolerance);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, degree.Millidegrees, MillidegreesTolerance);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, degree.Milliradians, MilliradiansTolerance);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, degree.Nanodegrees, NanodegreesTolerance);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, degree.Nanoradians, NanoradiansTolerance);
- AssertEx.EqualTolerance(RadiansInOneDegree, degree.Radians, RadiansTolerance);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, degree.Revolutions, RevolutionsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Arcminute).Arcminutes, ArcminutesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Arcsecond).Arcseconds, ArcsecondsTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Centiradian).Centiradians, CentiradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Deciradian).Deciradians, DeciradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Degree).Degrees, DegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Gradian).Gradians, GradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Microdegree).Microdegrees, MicrodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Microradian).Microradians, MicroradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Millidegree).Millidegrees, MillidegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Milliradian).Milliradians, MilliradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Nanodegree).Nanodegrees, NanodegreesTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Nanoradian).Nanoradians, NanoradiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Radian).Radians, RadiansTolerance);
- AssertEx.EqualTolerance(1, Angle.From(1, AngleUnit.Revolution).Revolutions, RevolutionsTolerance);
- }
-
- [Fact]
- public void FromDegrees_WithInfinityValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Angle.FromDegrees(double.PositiveInfinity));
- Assert.Throws(() => Angle.FromDegrees(double.NegativeInfinity));
- }
-
- [Fact]
- public void FromDegrees_WithNanValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Angle.FromDegrees(double.NaN));
- }
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, degree.As(AngleUnit.Deciradian), DeciradiansTolerance);
- AssertEx.EqualTolerance(DegreesInOneDegree, degree.As(AngleUnit.Degree), DegreesTolerance);
- AssertEx.EqualTolerance(GradiansInOneDegree, degree.As(AngleUnit.Gradian), GradiansTolerance);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, degree.As(AngleUnit.Microdegree), MicrodegreesTolerance);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, degree.As(AngleUnit.Microradian), MicroradiansTolerance);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, degree.As(AngleUnit.Millidegree), MillidegreesTolerance);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, degree.As(AngleUnit.Milliradian), MilliradiansTolerance);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, degree.As(AngleUnit.Nanodegree), NanodegreesTolerance);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, degree.As(AngleUnit.Nanoradian), NanoradiansTolerance);
- AssertEx.EqualTolerance(RadiansInOneDegree, degree.As(AngleUnit.Radian), RadiansTolerance);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, degree.As(AngleUnit.Revolution), RevolutionsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var degree = Angle.FromDegrees(1);
-
- var arcminuteQuantity = degree.ToUnit(AngleUnit.Arcminute);
- AssertEx.EqualTolerance(ArcminutesInOneDegree, (double)arcminuteQuantity.Value, ArcminutesTolerance);
- Assert.Equal(AngleUnit.Arcminute, arcminuteQuantity.Unit);
-
- var arcsecondQuantity = degree.ToUnit(AngleUnit.Arcsecond);
- AssertEx.EqualTolerance(ArcsecondsInOneDegree, (double)arcsecondQuantity.Value, ArcsecondsTolerance);
- Assert.Equal(AngleUnit.Arcsecond, arcsecondQuantity.Unit);
-
- var centiradianQuantity = degree.ToUnit(AngleUnit.Centiradian);
- AssertEx.EqualTolerance(CentiradiansInOneDegree, (double)centiradianQuantity.Value, CentiradiansTolerance);
- Assert.Equal(AngleUnit.Centiradian, centiradianQuantity.Unit);
-
- var deciradianQuantity = degree.ToUnit(AngleUnit.Deciradian);
- AssertEx.EqualTolerance(DeciradiansInOneDegree, (double)deciradianQuantity.Value, DeciradiansTolerance);
- Assert.Equal(AngleUnit.Deciradian, deciradianQuantity.Unit);
-
- var degreeQuantity = degree.ToUnit(AngleUnit.Degree);
- AssertEx.EqualTolerance(DegreesInOneDegree, (double)degreeQuantity.Value, DegreesTolerance);
- Assert.Equal(AngleUnit.Degree, degreeQuantity.Unit);
-
- var gradianQuantity = degree.ToUnit(AngleUnit.Gradian);
- AssertEx.EqualTolerance(GradiansInOneDegree, (double)gradianQuantity.Value, GradiansTolerance);
- Assert.Equal(AngleUnit.Gradian, gradianQuantity.Unit);
-
- var microdegreeQuantity = degree.ToUnit(AngleUnit.Microdegree);
- AssertEx.EqualTolerance(MicrodegreesInOneDegree, (double)microdegreeQuantity.Value, MicrodegreesTolerance);
- Assert.Equal(AngleUnit.Microdegree, microdegreeQuantity.Unit);
-
- var microradianQuantity = degree.ToUnit(AngleUnit.Microradian);
- AssertEx.EqualTolerance(MicroradiansInOneDegree, (double)microradianQuantity.Value, MicroradiansTolerance);
- Assert.Equal(AngleUnit.Microradian, microradianQuantity.Unit);
-
- var millidegreeQuantity = degree.ToUnit(AngleUnit.Millidegree);
- AssertEx.EqualTolerance(MillidegreesInOneDegree, (double)millidegreeQuantity.Value, MillidegreesTolerance);
- Assert.Equal(AngleUnit.Millidegree, millidegreeQuantity.Unit);
-
- var milliradianQuantity = degree.ToUnit(AngleUnit.Milliradian);
- AssertEx.EqualTolerance(MilliradiansInOneDegree, (double)milliradianQuantity.Value, MilliradiansTolerance);
- Assert.Equal(AngleUnit.Milliradian, milliradianQuantity.Unit);
-
- var nanodegreeQuantity = degree.ToUnit(AngleUnit.Nanodegree);
- AssertEx.EqualTolerance(NanodegreesInOneDegree, (double)nanodegreeQuantity.Value, NanodegreesTolerance);
- Assert.Equal(AngleUnit.Nanodegree, nanodegreeQuantity.Unit);
-
- var nanoradianQuantity = degree.ToUnit(AngleUnit.Nanoradian);
- AssertEx.EqualTolerance(NanoradiansInOneDegree, (double)nanoradianQuantity.Value, NanoradiansTolerance);
- Assert.Equal(AngleUnit.Nanoradian, nanoradianQuantity.Unit);
-
- var radianQuantity = degree.ToUnit(AngleUnit.Radian);
- AssertEx.EqualTolerance(RadiansInOneDegree, (double)radianQuantity.Value, RadiansTolerance);
- Assert.Equal(AngleUnit.Radian, radianQuantity.Unit);
-
- var revolutionQuantity = degree.ToUnit(AngleUnit.Revolution);
- AssertEx.EqualTolerance(RevolutionsInOneDegree, (double)revolutionQuantity.Value, RevolutionsTolerance);
- Assert.Equal(AngleUnit.Revolution, revolutionQuantity.Unit);
- }
-
- [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);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Angle v = Angle.FromDegrees(1);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Angle oneDegree = Angle.FromDegrees(1);
- Angle twoDegrees = Angle.FromDegrees(2);
-
- Assert.True(oneDegree < twoDegrees);
- Assert.True(oneDegree <= twoDegrees);
- Assert.True(twoDegrees > oneDegree);
- Assert.True(twoDegrees >= oneDegree);
-
- Assert.False(oneDegree > twoDegrees);
- Assert.False(oneDegree >= twoDegrees);
- Assert.False(twoDegrees < oneDegree);
- Assert.False(twoDegrees <= oneDegree);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.Throws(() => degree.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.Throws(() => degree.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- Angle v = Angle.FromDegrees(1);
- Assert.True(v.Equals(Angle.FromDegrees(1), DegreesTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(Angle.Zero, DegreesTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.False(degree.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Angle degree = Angle.FromDegrees(1);
- Assert.False(degree.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AngleUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AngleUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
deleted file mode 100644
index fa4c403cd7..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ApparentEnergyTestsBase.g.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ApparentEnergy 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ApparentEnergyUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
deleted file mode 100644
index 061fbb9aae..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ApparentPowerTestsBase.g.cs
+++ /dev/null
@@ -1,254 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ApparentPower 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ApparentPowerUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
deleted file mode 100644
index b6120fd28a..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaDensityTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- AreaDensity 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AreaDensityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AreaDensityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
deleted file mode 100644
index 10207a9f29..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaMomentOfInertiaTestsBase.g.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- AreaMomentOfInertia 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AreaMomentOfInertiaUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
deleted file mode 100644
index 205d6d77df..0000000000
--- a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs
+++ /dev/null
@@ -1,344 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 Area.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class AreaTestsBase
- {
- protected abstract double AcresInOneSquareMeter { get; }
- protected abstract double HectaresInOneSquareMeter { get; }
- protected abstract double SquareCentimetersInOneSquareMeter { get; }
- protected abstract double SquareDecimetersInOneSquareMeter { get; }
- protected abstract double SquareFeetInOneSquareMeter { get; }
- protected abstract double SquareInchesInOneSquareMeter { get; }
- protected abstract double SquareKilometersInOneSquareMeter { get; }
- protected abstract double SquareMetersInOneSquareMeter { get; }
- protected abstract double SquareMicrometersInOneSquareMeter { get; }
- protected abstract double SquareMilesInOneSquareMeter { get; }
- protected abstract double SquareMillimetersInOneSquareMeter { get; }
- protected abstract double SquareYardsInOneSquareMeter { get; }
- protected abstract double UsSurveySquareFeetInOneSquareMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double AcresTolerance { get { return 1e-5; } }
- protected virtual double HectaresTolerance { get { return 1e-5; } }
- protected virtual double SquareCentimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareDecimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareFeetTolerance { get { return 1e-5; } }
- protected virtual double SquareInchesTolerance { get { return 1e-5; } }
- protected virtual double SquareKilometersTolerance { get { return 1e-5; } }
- protected virtual double SquareMetersTolerance { get { return 1e-5; } }
- protected virtual double SquareMicrometersTolerance { get { return 1e-5; } }
- protected virtual double SquareMilesTolerance { get { return 1e-5; } }
- protected virtual double SquareMillimetersTolerance { get { return 1e-5; } }
- protected virtual double SquareYardsTolerance { get { return 1e-5; } }
- protected virtual double UsSurveySquareFeetTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new Area((double)0.0, AreaUnit.Undefined));
- }
-
- [Fact]
- public void Ctor_WithInfinityValue_ThrowsArgumentException()
- {
- 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));
- }
-
- [Fact]
- public void SquareMeterToAreaUnits()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.Acres, AcresTolerance);
- AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.Hectares, HectaresTolerance);
- AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.SquareCentimeters, SquareCentimetersTolerance);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.SquareDecimeters, SquareDecimetersTolerance);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, squaremeter.SquareFeet, SquareFeetTolerance);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, squaremeter.SquareInches, SquareInchesTolerance);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, squaremeter.SquareKilometers, SquareKilometersTolerance);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, squaremeter.SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, squaremeter.SquareMicrometers, SquareMicrometersTolerance);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, squaremeter.SquareMiles, SquareMilesTolerance);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, squaremeter.SquareMillimeters, SquareMillimetersTolerance);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, squaremeter.SquareYards, SquareYardsTolerance);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, squaremeter.UsSurveySquareFeet, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Acre).Acres, AcresTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Hectare).Hectares, HectaresTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareCentimeter).SquareCentimeters, SquareCentimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareDecimeter).SquareDecimeters, SquareDecimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareFoot).SquareFeet, SquareFeetTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareInch).SquareInches, SquareInchesTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareKilometer).SquareKilometers, SquareKilometersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMeter).SquareMeters, SquareMetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMicrometer).SquareMicrometers, SquareMicrometersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMile).SquareMiles, SquareMilesTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareMillimeter).SquareMillimeters, SquareMillimetersTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareYard).SquareYards, SquareYardsTolerance);
- AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.UsSurveySquareFoot).UsSurveySquareFeet, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void FromSquareMeters_WithInfinityValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Area.FromSquareMeters(double.PositiveInfinity));
- Assert.Throws(() => Area.FromSquareMeters(double.NegativeInfinity));
- }
-
- [Fact]
- public void FromSquareMeters_WithNanValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Area.FromSquareMeters(double.NaN));
- }
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareDecimeter), SquareDecimetersTolerance);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, squaremeter.As(AreaUnit.SquareFoot), SquareFeetTolerance);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, squaremeter.As(AreaUnit.SquareInch), SquareInchesTolerance);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, squaremeter.As(AreaUnit.SquareKilometer), SquareKilometersTolerance);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMeter), SquareMetersTolerance);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMicrometer), SquareMicrometersTolerance);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, squaremeter.As(AreaUnit.SquareMile), SquareMilesTolerance);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareMillimeter), SquareMillimetersTolerance);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, squaremeter.As(AreaUnit.SquareYard), SquareYardsTolerance);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, squaremeter.As(AreaUnit.UsSurveySquareFoot), UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var squaremeter = Area.FromSquareMeters(1);
-
- var acreQuantity = squaremeter.ToUnit(AreaUnit.Acre);
- AssertEx.EqualTolerance(AcresInOneSquareMeter, (double)acreQuantity.Value, AcresTolerance);
- Assert.Equal(AreaUnit.Acre, acreQuantity.Unit);
-
- var hectareQuantity = squaremeter.ToUnit(AreaUnit.Hectare);
- AssertEx.EqualTolerance(HectaresInOneSquareMeter, (double)hectareQuantity.Value, HectaresTolerance);
- Assert.Equal(AreaUnit.Hectare, hectareQuantity.Unit);
-
- var squarecentimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareCentimeter);
- AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, (double)squarecentimeterQuantity.Value, SquareCentimetersTolerance);
- Assert.Equal(AreaUnit.SquareCentimeter, squarecentimeterQuantity.Unit);
-
- var squaredecimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareDecimeter);
- AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, (double)squaredecimeterQuantity.Value, SquareDecimetersTolerance);
- Assert.Equal(AreaUnit.SquareDecimeter, squaredecimeterQuantity.Unit);
-
- var squarefootQuantity = squaremeter.ToUnit(AreaUnit.SquareFoot);
- AssertEx.EqualTolerance(SquareFeetInOneSquareMeter, (double)squarefootQuantity.Value, SquareFeetTolerance);
- Assert.Equal(AreaUnit.SquareFoot, squarefootQuantity.Unit);
-
- var squareinchQuantity = squaremeter.ToUnit(AreaUnit.SquareInch);
- AssertEx.EqualTolerance(SquareInchesInOneSquareMeter, (double)squareinchQuantity.Value, SquareInchesTolerance);
- Assert.Equal(AreaUnit.SquareInch, squareinchQuantity.Unit);
-
- var squarekilometerQuantity = squaremeter.ToUnit(AreaUnit.SquareKilometer);
- AssertEx.EqualTolerance(SquareKilometersInOneSquareMeter, (double)squarekilometerQuantity.Value, SquareKilometersTolerance);
- Assert.Equal(AreaUnit.SquareKilometer, squarekilometerQuantity.Unit);
-
- var squaremeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMeter);
- AssertEx.EqualTolerance(SquareMetersInOneSquareMeter, (double)squaremeterQuantity.Value, SquareMetersTolerance);
- Assert.Equal(AreaUnit.SquareMeter, squaremeterQuantity.Unit);
-
- var squaremicrometerQuantity = squaremeter.ToUnit(AreaUnit.SquareMicrometer);
- AssertEx.EqualTolerance(SquareMicrometersInOneSquareMeter, (double)squaremicrometerQuantity.Value, SquareMicrometersTolerance);
- Assert.Equal(AreaUnit.SquareMicrometer, squaremicrometerQuantity.Unit);
-
- var squaremileQuantity = squaremeter.ToUnit(AreaUnit.SquareMile);
- AssertEx.EqualTolerance(SquareMilesInOneSquareMeter, (double)squaremileQuantity.Value, SquareMilesTolerance);
- Assert.Equal(AreaUnit.SquareMile, squaremileQuantity.Unit);
-
- var squaremillimeterQuantity = squaremeter.ToUnit(AreaUnit.SquareMillimeter);
- AssertEx.EqualTolerance(SquareMillimetersInOneSquareMeter, (double)squaremillimeterQuantity.Value, SquareMillimetersTolerance);
- Assert.Equal(AreaUnit.SquareMillimeter, squaremillimeterQuantity.Unit);
-
- var squareyardQuantity = squaremeter.ToUnit(AreaUnit.SquareYard);
- AssertEx.EqualTolerance(SquareYardsInOneSquareMeter, (double)squareyardQuantity.Value, SquareYardsTolerance);
- Assert.Equal(AreaUnit.SquareYard, squareyardQuantity.Unit);
-
- var ussurveysquarefootQuantity = squaremeter.ToUnit(AreaUnit.UsSurveySquareFoot);
- AssertEx.EqualTolerance(UsSurveySquareFeetInOneSquareMeter, (double)ussurveysquarefootQuantity.Value, UsSurveySquareFeetTolerance);
- Assert.Equal(AreaUnit.UsSurveySquareFoot, ussurveysquarefootQuantity.Unit);
- }
-
- [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.FromSquareYards(squaremeter.SquareYards).SquareMeters, SquareYardsTolerance);
- AssertEx.EqualTolerance(1, Area.FromUsSurveySquareFeet(squaremeter.UsSurveySquareFeet).SquareMeters, UsSurveySquareFeetTolerance);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- Area v = Area.FromSquareMeters(1);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Area oneSquareMeter = Area.FromSquareMeters(1);
- Area twoSquareMeters = Area.FromSquareMeters(2);
-
- Assert.True(oneSquareMeter < twoSquareMeters);
- Assert.True(oneSquareMeter <= twoSquareMeters);
- Assert.True(twoSquareMeters > oneSquareMeter);
- Assert.True(twoSquareMeters >= oneSquareMeter);
-
- Assert.False(oneSquareMeter > twoSquareMeters);
- Assert.False(oneSquareMeter >= twoSquareMeters);
- Assert.False(twoSquareMeters < oneSquareMeter);
- Assert.False(twoSquareMeters <= oneSquareMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.Throws(() => squaremeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.Throws(() => squaremeter.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- Area v = Area.FromSquareMeters(1);
- Assert.True(v.Equals(Area.FromSquareMeters(1), SquareMetersTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(Area.Zero, SquareMetersTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.False(squaremeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Area squaremeter = Area.FromSquareMeters(1);
- Assert.False(squaremeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(AreaUnit.Undefined, Area.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(AreaUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == AreaUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
deleted file mode 100644
index 3050aa4ad4..0000000000
--- a/UnitsNet.Tests/GeneratedCode/BitRateTestsBase.g.cs
+++ /dev/null
@@ -1,450 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 BitRate.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class BitRateTestsBase
- {
- protected abstract double BitsPerSecondInOneBitPerSecond { get; }
- protected abstract double BytesPerSecondInOneBitPerSecond { get; }
- protected abstract double ExabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double ExabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double GibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double GibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double GigabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double GigabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double KibibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double KibibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double KilobitsPerSecondInOneBitPerSecond { get; }
- protected abstract double KilobytesPerSecondInOneBitPerSecond { get; }
- protected abstract double MebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double MebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double MegabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double MegabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double PebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double PebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double PetabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double PetabytesPerSecondInOneBitPerSecond { get; }
- protected abstract double TebibitsPerSecondInOneBitPerSecond { get; }
- protected abstract double TebibytesPerSecondInOneBitPerSecond { get; }
- protected abstract double TerabitsPerSecondInOneBitPerSecond { get; }
- protected abstract double TerabytesPerSecondInOneBitPerSecond { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double BitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double BytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } }
- protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new BitRate((decimal)0.0, BitRateUnit.Undefined));
- }
-
-
- [Fact]
- public void BitPerSecondToBitRateUnits()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, bitpersecond.BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, bitpersecond.BytesPerSecond, BytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, bitpersecond.ExabitsPerSecond, ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, bitpersecond.ExabytesPerSecond, ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, bitpersecond.ExbibitsPerSecond, ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, bitpersecond.ExbibytesPerSecond, ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, bitpersecond.GibibitsPerSecond, GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, bitpersecond.GibibytesPerSecond, GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, bitpersecond.GigabitsPerSecond, GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, bitpersecond.GigabytesPerSecond, GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, bitpersecond.KibibitsPerSecond, KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, bitpersecond.KibibytesPerSecond, KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, bitpersecond.KilobitsPerSecond, KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, bitpersecond.KilobytesPerSecond, KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, bitpersecond.MebibitsPerSecond, MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, bitpersecond.MebibytesPerSecond, MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, bitpersecond.MegabitsPerSecond, MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, bitpersecond.MegabytesPerSecond, MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, bitpersecond.PebibitsPerSecond, PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, bitpersecond.PebibytesPerSecond, PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, bitpersecond.PetabitsPerSecond, PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, bitpersecond.PetabytesPerSecond, PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, bitpersecond.TebibitsPerSecond, TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, bitpersecond.TebibytesPerSecond, TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, bitpersecond.TerabitsPerSecond, TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, bitpersecond.TerabytesPerSecond, TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.BitPerSecond).BitsPerSecond, BitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.BytePerSecond).BytesPerSecond, BytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExabitPerSecond).ExabitsPerSecond, ExabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExabytePerSecond).ExabytesPerSecond, ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExbibitPerSecond).ExbibitsPerSecond, ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.ExbibytePerSecond).ExbibytesPerSecond, ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GibibitPerSecond).GibibitsPerSecond, GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GibibytePerSecond).GibibytesPerSecond, GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GigabitPerSecond).GigabitsPerSecond, GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.GigabytePerSecond).GigabytesPerSecond, GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KibibitPerSecond).KibibitsPerSecond, KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KibibytePerSecond).KibibytesPerSecond, KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KilobitPerSecond).KilobitsPerSecond, KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.KilobytePerSecond).KilobytesPerSecond, KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MebibitPerSecond).MebibitsPerSecond, MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MebibytePerSecond).MebibytesPerSecond, MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MegabitPerSecond).MegabitsPerSecond, MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.MegabytePerSecond).MegabytesPerSecond, MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PebibitPerSecond).PebibitsPerSecond, PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PebibytePerSecond).PebibytesPerSecond, PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PetabitPerSecond).PetabitsPerSecond, PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.PetabytePerSecond).PetabytesPerSecond, PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TebibitPerSecond).TebibitsPerSecond, TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TebibytePerSecond).TebibytesPerSecond, TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TerabitPerSecond).TerabitsPerSecond, TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(1, BitRate.From(1, BitRateUnit.TerabytePerSecond).TerabytesPerSecond, TerabytesPerSecondTolerance);
- }
-
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExabytePerSecond), ExabytesPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExbibitPerSecond), ExbibitsPerSecondTolerance);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.ExbibytePerSecond), ExbibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GibibitPerSecond), GibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GibibytePerSecond), GibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GigabitPerSecond), GigabitsPerSecondTolerance);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.GigabytePerSecond), GigabytesPerSecondTolerance);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KibibitPerSecond), KibibitsPerSecondTolerance);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KibibytePerSecond), KibibytesPerSecondTolerance);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KilobitPerSecond), KilobitsPerSecondTolerance);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.KilobytePerSecond), KilobytesPerSecondTolerance);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MebibitPerSecond), MebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MebibytePerSecond), MebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MegabitPerSecond), MegabitsPerSecondTolerance);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.MegabytePerSecond), MegabytesPerSecondTolerance);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PebibitPerSecond), PebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PebibytePerSecond), PebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PetabitPerSecond), PetabitsPerSecondTolerance);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.PetabytePerSecond), PetabytesPerSecondTolerance);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TebibitPerSecond), TebibitsPerSecondTolerance);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TebibytePerSecond), TebibytesPerSecondTolerance);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TerabitPerSecond), TerabitsPerSecondTolerance);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, bitpersecond.As(BitRateUnit.TerabytePerSecond), TerabytesPerSecondTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var bitpersecond = BitRate.FromBitsPerSecond(1);
-
- var bitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BitPerSecond);
- AssertEx.EqualTolerance(BitsPerSecondInOneBitPerSecond, (double)bitpersecondQuantity.Value, BitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.BitPerSecond, bitpersecondQuantity.Unit);
-
- var bytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.BytePerSecond);
- AssertEx.EqualTolerance(BytesPerSecondInOneBitPerSecond, (double)bytepersecondQuantity.Value, BytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.BytePerSecond, bytepersecondQuantity.Unit);
-
- var exabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabitPerSecond);
- AssertEx.EqualTolerance(ExabitsPerSecondInOneBitPerSecond, (double)exabitpersecondQuantity.Value, ExabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExabitPerSecond, exabitpersecondQuantity.Unit);
-
- var exabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExabytePerSecond);
- AssertEx.EqualTolerance(ExabytesPerSecondInOneBitPerSecond, (double)exabytepersecondQuantity.Value, ExabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExabytePerSecond, exabytepersecondQuantity.Unit);
-
- var exbibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibitPerSecond);
- AssertEx.EqualTolerance(ExbibitsPerSecondInOneBitPerSecond, (double)exbibitpersecondQuantity.Value, ExbibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExbibitPerSecond, exbibitpersecondQuantity.Unit);
-
- var exbibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.ExbibytePerSecond);
- AssertEx.EqualTolerance(ExbibytesPerSecondInOneBitPerSecond, (double)exbibytepersecondQuantity.Value, ExbibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.ExbibytePerSecond, exbibytepersecondQuantity.Unit);
-
- var gibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibitPerSecond);
- AssertEx.EqualTolerance(GibibitsPerSecondInOneBitPerSecond, (double)gibibitpersecondQuantity.Value, GibibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.GibibitPerSecond, gibibitpersecondQuantity.Unit);
-
- var gibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GibibytePerSecond);
- AssertEx.EqualTolerance(GibibytesPerSecondInOneBitPerSecond, (double)gibibytepersecondQuantity.Value, GibibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.GibibytePerSecond, gibibytepersecondQuantity.Unit);
-
- var gigabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabitPerSecond);
- AssertEx.EqualTolerance(GigabitsPerSecondInOneBitPerSecond, (double)gigabitpersecondQuantity.Value, GigabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.GigabitPerSecond, gigabitpersecondQuantity.Unit);
-
- var gigabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.GigabytePerSecond);
- AssertEx.EqualTolerance(GigabytesPerSecondInOneBitPerSecond, (double)gigabytepersecondQuantity.Value, GigabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.GigabytePerSecond, gigabytepersecondQuantity.Unit);
-
- var kibibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibitPerSecond);
- AssertEx.EqualTolerance(KibibitsPerSecondInOneBitPerSecond, (double)kibibitpersecondQuantity.Value, KibibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.KibibitPerSecond, kibibitpersecondQuantity.Unit);
-
- var kibibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KibibytePerSecond);
- AssertEx.EqualTolerance(KibibytesPerSecondInOneBitPerSecond, (double)kibibytepersecondQuantity.Value, KibibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.KibibytePerSecond, kibibytepersecondQuantity.Unit);
-
- var kilobitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobitPerSecond);
- AssertEx.EqualTolerance(KilobitsPerSecondInOneBitPerSecond, (double)kilobitpersecondQuantity.Value, KilobitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.KilobitPerSecond, kilobitpersecondQuantity.Unit);
-
- var kilobytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.KilobytePerSecond);
- AssertEx.EqualTolerance(KilobytesPerSecondInOneBitPerSecond, (double)kilobytepersecondQuantity.Value, KilobytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.KilobytePerSecond, kilobytepersecondQuantity.Unit);
-
- var mebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibitPerSecond);
- AssertEx.EqualTolerance(MebibitsPerSecondInOneBitPerSecond, (double)mebibitpersecondQuantity.Value, MebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.MebibitPerSecond, mebibitpersecondQuantity.Unit);
-
- var mebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MebibytePerSecond);
- AssertEx.EqualTolerance(MebibytesPerSecondInOneBitPerSecond, (double)mebibytepersecondQuantity.Value, MebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.MebibytePerSecond, mebibytepersecondQuantity.Unit);
-
- var megabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabitPerSecond);
- AssertEx.EqualTolerance(MegabitsPerSecondInOneBitPerSecond, (double)megabitpersecondQuantity.Value, MegabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.MegabitPerSecond, megabitpersecondQuantity.Unit);
-
- var megabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.MegabytePerSecond);
- AssertEx.EqualTolerance(MegabytesPerSecondInOneBitPerSecond, (double)megabytepersecondQuantity.Value, MegabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.MegabytePerSecond, megabytepersecondQuantity.Unit);
-
- var pebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibitPerSecond);
- AssertEx.EqualTolerance(PebibitsPerSecondInOneBitPerSecond, (double)pebibitpersecondQuantity.Value, PebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.PebibitPerSecond, pebibitpersecondQuantity.Unit);
-
- var pebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PebibytePerSecond);
- AssertEx.EqualTolerance(PebibytesPerSecondInOneBitPerSecond, (double)pebibytepersecondQuantity.Value, PebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.PebibytePerSecond, pebibytepersecondQuantity.Unit);
-
- var petabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabitPerSecond);
- AssertEx.EqualTolerance(PetabitsPerSecondInOneBitPerSecond, (double)petabitpersecondQuantity.Value, PetabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.PetabitPerSecond, petabitpersecondQuantity.Unit);
-
- var petabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.PetabytePerSecond);
- AssertEx.EqualTolerance(PetabytesPerSecondInOneBitPerSecond, (double)petabytepersecondQuantity.Value, PetabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.PetabytePerSecond, petabytepersecondQuantity.Unit);
-
- var tebibitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibitPerSecond);
- AssertEx.EqualTolerance(TebibitsPerSecondInOneBitPerSecond, (double)tebibitpersecondQuantity.Value, TebibitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.TebibitPerSecond, tebibitpersecondQuantity.Unit);
-
- var tebibytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TebibytePerSecond);
- AssertEx.EqualTolerance(TebibytesPerSecondInOneBitPerSecond, (double)tebibytepersecondQuantity.Value, TebibytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.TebibytePerSecond, tebibytepersecondQuantity.Unit);
-
- var terabitpersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabitPerSecond);
- AssertEx.EqualTolerance(TerabitsPerSecondInOneBitPerSecond, (double)terabitpersecondQuantity.Value, TerabitsPerSecondTolerance);
- Assert.Equal(BitRateUnit.TerabitPerSecond, terabitpersecondQuantity.Unit);
-
- var terabytepersecondQuantity = bitpersecond.ToUnit(BitRateUnit.TerabytePerSecond);
- AssertEx.EqualTolerance(TerabytesPerSecondInOneBitPerSecond, (double)terabytepersecondQuantity.Value, TerabytesPerSecondTolerance);
- Assert.Equal(BitRateUnit.TerabytePerSecond, terabytepersecondQuantity.Unit);
- }
-
- [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);
- }
-
- [Fact]
- public void ArithmeticOperators()
- {
- BitRate v = BitRate.FromBitsPerSecond(1);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- BitRate oneBitPerSecond = BitRate.FromBitsPerSecond(1);
- BitRate twoBitsPerSecond = BitRate.FromBitsPerSecond(2);
-
- Assert.True(oneBitPerSecond < twoBitsPerSecond);
- Assert.True(oneBitPerSecond <= twoBitsPerSecond);
- Assert.True(twoBitsPerSecond > oneBitPerSecond);
- Assert.True(twoBitsPerSecond >= oneBitPerSecond);
-
- Assert.False(oneBitPerSecond > twoBitsPerSecond);
- Assert.False(oneBitPerSecond >= twoBitsPerSecond);
- Assert.False(twoBitsPerSecond < oneBitPerSecond);
- Assert.False(twoBitsPerSecond <= oneBitPerSecond);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.Throws(() => bitpersecond.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.Throws(() => bitpersecond.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- BitRate v = BitRate.FromBitsPerSecond(1);
- Assert.True(v.Equals(BitRate.FromBitsPerSecond(1), BitsPerSecondTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(BitRate.Zero, BitsPerSecondTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.False(bitpersecond.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- BitRate bitpersecond = BitRate.FromBitsPerSecond(1);
- Assert.False(bitpersecond.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(BitRateUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == BitRateUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
deleted file mode 100644
index c424b3e7fb..0000000000
--- a/UnitsNet.Tests/GeneratedCode/BrakeSpecificFuelConsumptionTestsBase.g.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- BrakeSpecificFuelConsumption 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == BrakeSpecificFuelConsumptionUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
deleted file mode 100644
index 08850f7618..0000000000
--- a/UnitsNet.Tests/GeneratedCode/CapacitanceTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double FaradsTolerance { 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);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Capacitance.From(1, CapacitanceUnit.Farad).Farads, FaradsTolerance);
- }
-
- [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);
- }
-
- [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);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- Capacitance farad = Capacitance.FromFarads(1);
- AssertEx.EqualTolerance(1, Capacitance.FromFarads(farad.Farads).Farads, FaradsTolerance);
- }
-
- [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 EqualsIsImplemented()
- {
- Capacitance 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(CapacitanceUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == CapacitanceUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
deleted file mode 100644
index 7c9cfc75cb..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DensityTestsBase.g.cs
+++ /dev/null
@@ -1,594 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 Density.
- ///
-// ReSharper disable once PartialTypeWithSinglePart
- public abstract partial class DensityTestsBase
- {
- protected abstract double CentigramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double CentigramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double CentigramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double DecigramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double GramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double KilopoundsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double KilopoundsPerCubicInchInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MicrogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double MilligramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double NanogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerDeciLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerLiterInOneKilogramPerCubicMeter { get; }
- protected abstract double PicogramsPerMilliliterInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerCubicInchInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerImperialGallonInOneKilogramPerCubicMeter { get; }
- protected abstract double PoundsPerUSGallonInOneKilogramPerCubicMeter { get; }
- protected abstract double SlugsPerCubicFootInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicCentimeterInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicMeterInOneKilogramPerCubicMeter { get; }
- protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CentigramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } }
- protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerDeciLiterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } }
- protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } }
- protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } }
- protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } }
- protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } }
-// ReSharper restore VirtualMemberNeverOverriden.Global
-
- [Fact]
- public void Ctor_WithUndefinedUnit_ThrowsArgumentException()
- {
- Assert.Throws(() => new Density((double)0.0, DensityUnit.Undefined));
- }
-
- [Fact]
- public void Ctor_WithInfinityValue_ThrowsArgumentException()
- {
- 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));
- }
-
- [Fact]
- public void KilogramPerCubicMeterToDensityUnits()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerLiter, CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.CentigramsPerMilliliter, CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerDeciLiter, DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerLiter, DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.DecigramsPerMilliliter, DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicMeter, GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerDeciLiter, GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerLiter, GramsPerLiterTolerance);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.GramsPerMilliliter, GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerDeciLiter, MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerLiter, MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerDeciLiter, MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerLiter, MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.MilligramsPerMilliliter, MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerDeciLiter, NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerLiter, NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.NanogramsPerMilliliter, NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerDeciLiter, PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerLiter, PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.PicogramsPerMilliliter, PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerCubicFoot, PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerCubicInch, PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerImperialGallon, PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.PoundsPerUSGallon, PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.SlugsPerCubicFoot, SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicMeter, TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerDeciliter).CentigramsPerDeciLiter, CentigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerLiter).CentigramsPerLiter, CentigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.CentigramPerMilliliter).CentigramsPerMilliliter, CentigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerDeciliter).DecigramsPerDeciLiter, DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerLiter).DecigramsPerLiter, DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.DecigramPerMilliliter).DecigramsPerMilliliter, DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicCentimeter).GramsPerCubicCentimeter, GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicMeter).GramsPerCubicMeter, GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerCubicMillimeter).GramsPerCubicMillimeter, GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerDeciliter).GramsPerDeciLiter, GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerLiter).GramsPerLiter, GramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.GramPerMilliliter).GramsPerMilliliter, GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicCentimeter).KilogramsPerCubicCentimeter, KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicMeter).KilogramsPerCubicMeter, KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilogramPerCubicMillimeter).KilogramsPerCubicMillimeter, KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilopoundPerCubicFoot).KilopoundsPerCubicFoot, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.KilopoundPerCubicInch).KilopoundsPerCubicInch, KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerDeciliter).MicrogramsPerDeciLiter, MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerLiter).MicrogramsPerLiter, MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MicrogramPerMilliliter).MicrogramsPerMilliliter, MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerCubicMeter).MilligramsPerCubicMeter, MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerDeciliter).MilligramsPerDeciLiter, MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerLiter).MilligramsPerLiter, MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.MilligramPerMilliliter).MilligramsPerMilliliter, MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerDeciliter).NanogramsPerDeciLiter, NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerLiter).NanogramsPerLiter, NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.NanogramPerMilliliter).NanogramsPerMilliliter, NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerDeciliter).PicogramsPerDeciLiter, PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerLiter).PicogramsPerLiter, PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PicogramPerMilliliter).PicogramsPerMilliliter, PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerCubicFoot).PoundsPerCubicFoot, PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerCubicInch).PoundsPerCubicInch, PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerImperialGallon).PoundsPerImperialGallon, PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.PoundPerUSGallon).PoundsPerUSGallon, PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.SlugPerCubicFoot).SlugsPerCubicFoot, SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicCentimeter).TonnesPerCubicCentimeter, TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicMeter).TonnesPerCubicMeter, TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(1, Density.From(1, DensityUnit.TonnePerCubicMillimeter).TonnesPerCubicMillimeter, TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void FromKilogramsPerCubicMeter_WithInfinityValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.PositiveInfinity));
- Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NegativeInfinity));
- }
-
- [Fact]
- public void FromKilogramsPerCubicMeter_WithNanValue_ThrowsArgumentException()
- {
- Assert.Throws(() => Density.FromKilogramsPerCubicMeter(double.NaN));
- }
-
- [Fact]
- public void As()
- {
- 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);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerDeciliter), DecigramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerLiter), DecigramsPerLiterTolerance);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.DecigramPerMilliliter), DecigramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicCentimeter), GramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicMeter), GramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerCubicMillimeter), GramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerDeciliter), GramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerLiter), GramsPerLiterTolerance);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.GramPerMilliliter), GramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicCentimeter), KilogramsPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicMeter), KilogramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilogramPerCubicMillimeter), KilogramsPerCubicMillimeterTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilopoundPerCubicFoot), KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.KilopoundPerCubicInch), KilopoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerDeciliter), MicrogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerLiter), MicrogramsPerLiterTolerance);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MicrogramPerMilliliter), MicrogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerCubicMeter), MilligramsPerCubicMeterTolerance);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerDeciliter), MilligramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerLiter), MilligramsPerLiterTolerance);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.MilligramPerMilliliter), MilligramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerDeciliter), NanogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerLiter), NanogramsPerLiterTolerance);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.NanogramPerMilliliter), NanogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerDeciliter), PicogramsPerDeciLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerLiter), PicogramsPerLiterTolerance);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PicogramPerMilliliter), PicogramsPerMilliliterTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerCubicFoot), PoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerCubicInch), PoundsPerCubicInchTolerance);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerImperialGallon), PoundsPerImperialGallonTolerance);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.PoundPerUSGallon), PoundsPerUSGallonTolerance);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.SlugPerCubicFoot), SlugsPerCubicFootTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicCentimeter), TonnesPerCubicCentimeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicMeter), TonnesPerCubicMeterTolerance);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, kilogrampercubicmeter.As(DensityUnit.TonnePerCubicMillimeter), TonnesPerCubicMillimeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
-
- var centigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerDeciliter);
- AssertEx.EqualTolerance(CentigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)centigramperdeciliterQuantity.Value, CentigramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.CentigramPerDeciliter, centigramperdeciliterQuantity.Unit);
-
- var centigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerLiter);
- AssertEx.EqualTolerance(CentigramsPerLiterInOneKilogramPerCubicMeter, (double)centigramperliterQuantity.Value, CentigramsPerLiterTolerance);
- Assert.Equal(DensityUnit.CentigramPerLiter, centigramperliterQuantity.Unit);
-
- var centigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.CentigramPerMilliliter);
- AssertEx.EqualTolerance(CentigramsPerMilliliterInOneKilogramPerCubicMeter, (double)centigrampermilliliterQuantity.Value, CentigramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.CentigramPerMilliliter, centigrampermilliliterQuantity.Unit);
-
- var decigramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerDeciliter);
- AssertEx.EqualTolerance(DecigramsPerDeciLiterInOneKilogramPerCubicMeter, (double)decigramperdeciliterQuantity.Value, DecigramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.DecigramPerDeciliter, decigramperdeciliterQuantity.Unit);
-
- var decigramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerLiter);
- AssertEx.EqualTolerance(DecigramsPerLiterInOneKilogramPerCubicMeter, (double)decigramperliterQuantity.Value, DecigramsPerLiterTolerance);
- Assert.Equal(DensityUnit.DecigramPerLiter, decigramperliterQuantity.Unit);
-
- var decigrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.DecigramPerMilliliter);
- AssertEx.EqualTolerance(DecigramsPerMilliliterInOneKilogramPerCubicMeter, (double)decigrampermilliliterQuantity.Value, DecigramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.DecigramPerMilliliter, decigrampermilliliterQuantity.Unit);
-
- var grampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicCentimeter);
- AssertEx.EqualTolerance(GramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)grampercubiccentimeterQuantity.Value, GramsPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicCentimeter, grampercubiccentimeterQuantity.Unit);
-
- var grampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMeter);
- AssertEx.EqualTolerance(GramsPerCubicMeterInOneKilogramPerCubicMeter, (double)grampercubicmeterQuantity.Value, GramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicMeter, grampercubicmeterQuantity.Unit);
-
- var grampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerCubicMillimeter);
- AssertEx.EqualTolerance(GramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)grampercubicmillimeterQuantity.Value, GramsPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.GramPerCubicMillimeter, grampercubicmillimeterQuantity.Unit);
-
- var gramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerDeciliter);
- AssertEx.EqualTolerance(GramsPerDeciLiterInOneKilogramPerCubicMeter, (double)gramperdeciliterQuantity.Value, GramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.GramPerDeciliter, gramperdeciliterQuantity.Unit);
-
- var gramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerLiter);
- AssertEx.EqualTolerance(GramsPerLiterInOneKilogramPerCubicMeter, (double)gramperliterQuantity.Value, GramsPerLiterTolerance);
- Assert.Equal(DensityUnit.GramPerLiter, gramperliterQuantity.Unit);
-
- var grampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.GramPerMilliliter);
- AssertEx.EqualTolerance(GramsPerMilliliterInOneKilogramPerCubicMeter, (double)grampermilliliterQuantity.Value, GramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.GramPerMilliliter, grampermilliliterQuantity.Unit);
-
- var kilogrampercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicCentimeter);
- AssertEx.EqualTolerance(KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter, (double)kilogrampercubiccentimeterQuantity.Value, KilogramsPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicCentimeter, kilogrampercubiccentimeterQuantity.Unit);
-
- var kilogrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMeter);
- AssertEx.EqualTolerance(KilogramsPerCubicMeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmeterQuantity.Value, KilogramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicMeter, kilogrampercubicmeterQuantity.Unit);
-
- var kilogrampercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilogramPerCubicMillimeter);
- AssertEx.EqualTolerance(KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter, (double)kilogrampercubicmillimeterQuantity.Value, KilogramsPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.KilogramPerCubicMillimeter, kilogrampercubicmillimeterQuantity.Unit);
-
- var kilopoundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicFoot);
- AssertEx.EqualTolerance(KilopoundsPerCubicFootInOneKilogramPerCubicMeter, (double)kilopoundpercubicfootQuantity.Value, KilopoundsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.KilopoundPerCubicFoot, kilopoundpercubicfootQuantity.Unit);
-
- var kilopoundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.KilopoundPerCubicInch);
- AssertEx.EqualTolerance(KilopoundsPerCubicInchInOneKilogramPerCubicMeter, (double)kilopoundpercubicinchQuantity.Value, KilopoundsPerCubicInchTolerance);
- Assert.Equal(DensityUnit.KilopoundPerCubicInch, kilopoundpercubicinchQuantity.Unit);
-
- var microgramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerDeciliter);
- AssertEx.EqualTolerance(MicrogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)microgramperdeciliterQuantity.Value, MicrogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerDeciliter, microgramperdeciliterQuantity.Unit);
-
- var microgramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerLiter);
- AssertEx.EqualTolerance(MicrogramsPerLiterInOneKilogramPerCubicMeter, (double)microgramperliterQuantity.Value, MicrogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerLiter, microgramperliterQuantity.Unit);
-
- var microgrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MicrogramPerMilliliter);
- AssertEx.EqualTolerance(MicrogramsPerMilliliterInOneKilogramPerCubicMeter, (double)microgrampermilliliterQuantity.Value, MicrogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.MicrogramPerMilliliter, microgrampermilliliterQuantity.Unit);
-
- var milligrampercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerCubicMeter);
- AssertEx.EqualTolerance(MilligramsPerCubicMeterInOneKilogramPerCubicMeter, (double)milligrampercubicmeterQuantity.Value, MilligramsPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.MilligramPerCubicMeter, milligrampercubicmeterQuantity.Unit);
-
- var milligramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerDeciliter);
- AssertEx.EqualTolerance(MilligramsPerDeciLiterInOneKilogramPerCubicMeter, (double)milligramperdeciliterQuantity.Value, MilligramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.MilligramPerDeciliter, milligramperdeciliterQuantity.Unit);
-
- var milligramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerLiter);
- AssertEx.EqualTolerance(MilligramsPerLiterInOneKilogramPerCubicMeter, (double)milligramperliterQuantity.Value, MilligramsPerLiterTolerance);
- Assert.Equal(DensityUnit.MilligramPerLiter, milligramperliterQuantity.Unit);
-
- var milligrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.MilligramPerMilliliter);
- AssertEx.EqualTolerance(MilligramsPerMilliliterInOneKilogramPerCubicMeter, (double)milligrampermilliliterQuantity.Value, MilligramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.MilligramPerMilliliter, milligrampermilliliterQuantity.Unit);
-
- var nanogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerDeciliter);
- AssertEx.EqualTolerance(NanogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)nanogramperdeciliterQuantity.Value, NanogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.NanogramPerDeciliter, nanogramperdeciliterQuantity.Unit);
-
- var nanogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerLiter);
- AssertEx.EqualTolerance(NanogramsPerLiterInOneKilogramPerCubicMeter, (double)nanogramperliterQuantity.Value, NanogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.NanogramPerLiter, nanogramperliterQuantity.Unit);
-
- var nanogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.NanogramPerMilliliter);
- AssertEx.EqualTolerance(NanogramsPerMilliliterInOneKilogramPerCubicMeter, (double)nanogrampermilliliterQuantity.Value, NanogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.NanogramPerMilliliter, nanogrampermilliliterQuantity.Unit);
-
- var picogramperdeciliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerDeciliter);
- AssertEx.EqualTolerance(PicogramsPerDeciLiterInOneKilogramPerCubicMeter, (double)picogramperdeciliterQuantity.Value, PicogramsPerDeciLiterTolerance);
- Assert.Equal(DensityUnit.PicogramPerDeciliter, picogramperdeciliterQuantity.Unit);
-
- var picogramperliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerLiter);
- AssertEx.EqualTolerance(PicogramsPerLiterInOneKilogramPerCubicMeter, (double)picogramperliterQuantity.Value, PicogramsPerLiterTolerance);
- Assert.Equal(DensityUnit.PicogramPerLiter, picogramperliterQuantity.Unit);
-
- var picogrampermilliliterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PicogramPerMilliliter);
- AssertEx.EqualTolerance(PicogramsPerMilliliterInOneKilogramPerCubicMeter, (double)picogrampermilliliterQuantity.Value, PicogramsPerMilliliterTolerance);
- Assert.Equal(DensityUnit.PicogramPerMilliliter, picogrampermilliliterQuantity.Unit);
-
- var poundpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicFoot);
- AssertEx.EqualTolerance(PoundsPerCubicFootInOneKilogramPerCubicMeter, (double)poundpercubicfootQuantity.Value, PoundsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.PoundPerCubicFoot, poundpercubicfootQuantity.Unit);
-
- var poundpercubicinchQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerCubicInch);
- AssertEx.EqualTolerance(PoundsPerCubicInchInOneKilogramPerCubicMeter, (double)poundpercubicinchQuantity.Value, PoundsPerCubicInchTolerance);
- Assert.Equal(DensityUnit.PoundPerCubicInch, poundpercubicinchQuantity.Unit);
-
- var poundperimperialgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerImperialGallon);
- AssertEx.EqualTolerance(PoundsPerImperialGallonInOneKilogramPerCubicMeter, (double)poundperimperialgallonQuantity.Value, PoundsPerImperialGallonTolerance);
- Assert.Equal(DensityUnit.PoundPerImperialGallon, poundperimperialgallonQuantity.Unit);
-
- var poundperusgallonQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.PoundPerUSGallon);
- AssertEx.EqualTolerance(PoundsPerUSGallonInOneKilogramPerCubicMeter, (double)poundperusgallonQuantity.Value, PoundsPerUSGallonTolerance);
- Assert.Equal(DensityUnit.PoundPerUSGallon, poundperusgallonQuantity.Unit);
-
- var slugpercubicfootQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.SlugPerCubicFoot);
- AssertEx.EqualTolerance(SlugsPerCubicFootInOneKilogramPerCubicMeter, (double)slugpercubicfootQuantity.Value, SlugsPerCubicFootTolerance);
- Assert.Equal(DensityUnit.SlugPerCubicFoot, slugpercubicfootQuantity.Unit);
-
- var tonnepercubiccentimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicCentimeter);
- AssertEx.EqualTolerance(TonnesPerCubicCentimeterInOneKilogramPerCubicMeter, (double)tonnepercubiccentimeterQuantity.Value, TonnesPerCubicCentimeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicCentimeter, tonnepercubiccentimeterQuantity.Unit);
-
- var tonnepercubicmeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMeter);
- AssertEx.EqualTolerance(TonnesPerCubicMeterInOneKilogramPerCubicMeter, (double)tonnepercubicmeterQuantity.Value, TonnesPerCubicMeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicMeter, tonnepercubicmeterQuantity.Unit);
-
- var tonnepercubicmillimeterQuantity = kilogrampercubicmeter.ToUnit(DensityUnit.TonnePerCubicMillimeter);
- AssertEx.EqualTolerance(TonnesPerCubicMillimeterInOneKilogramPerCubicMeter, (double)tonnepercubicmillimeterQuantity.Value, TonnesPerCubicMillimeterTolerance);
- Assert.Equal(DensityUnit.TonnePerCubicMillimeter, tonnepercubicmillimeterQuantity.Unit);
- }
-
- [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.FromKilopoundsPerCubicFoot(kilogrampercubicmeter.KilopoundsPerCubicFoot).KilogramsPerCubicMeter, KilopoundsPerCubicFootTolerance);
- AssertEx.EqualTolerance(1, Density.FromKilopoundsPerCubicInch(kilogrampercubicmeter.KilopoundsPerCubicInch).KilogramsPerCubicMeter, KilopoundsPerCubicInchTolerance);
- 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);
- AssertEx.EqualTolerance(-1, -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);
- }
-
- [Fact]
- public void ComparisonOperators()
- {
- Density oneKilogramPerCubicMeter = Density.FromKilogramsPerCubicMeter(1);
- Density twoKilogramsPerCubicMeter = Density.FromKilogramsPerCubicMeter(2);
-
- Assert.True(oneKilogramPerCubicMeter < twoKilogramsPerCubicMeter);
- Assert.True(oneKilogramPerCubicMeter <= twoKilogramsPerCubicMeter);
- Assert.True(twoKilogramsPerCubicMeter > oneKilogramPerCubicMeter);
- Assert.True(twoKilogramsPerCubicMeter >= oneKilogramPerCubicMeter);
-
- Assert.False(oneKilogramPerCubicMeter > twoKilogramsPerCubicMeter);
- Assert.False(oneKilogramPerCubicMeter >= twoKilogramsPerCubicMeter);
- Assert.False(twoKilogramsPerCubicMeter < oneKilogramPerCubicMeter);
- Assert.False(twoKilogramsPerCubicMeter <= oneKilogramPerCubicMeter);
- }
-
- [Fact]
- public void CompareToIsImplemented()
- {
- 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);
- }
-
- [Fact]
- public void CompareToThrowsOnTypeMismatch()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.Throws(() => kilogrampercubicmeter.CompareTo(new object()));
- }
-
- [Fact]
- public void CompareToThrowsOnNull()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.Throws(() => kilogrampercubicmeter.CompareTo(null));
- }
-
- [Fact]
- public void EqualsIsImplemented()
- {
- Density v = Density.FromKilogramsPerCubicMeter(1);
- Assert.True(v.Equals(Density.FromKilogramsPerCubicMeter(1), KilogramsPerCubicMeterTolerance, ComparisonType.Relative));
- Assert.False(v.Equals(Density.Zero, KilogramsPerCubicMeterTolerance, ComparisonType.Relative));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnTypeMismatch()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.False(kilogrampercubicmeter.Equals(new object()));
- }
-
- [Fact]
- public void EqualsReturnsFalseOnNull()
- {
- Density kilogrampercubicmeter = Density.FromKilogramsPerCubicMeter(1);
- Assert.False(kilogrampercubicmeter.Equals(null));
- }
-
- [Fact]
- public void UnitsDoesNotContainUndefined()
- {
- Assert.DoesNotContain(DensityUnit.Undefined, Density.Units);
- }
-
- [Fact]
- public void AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(DensityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == DensityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
deleted file mode 100644
index 72f080eb89..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DurationTestsBase.g.cs
+++ /dev/null
@@ -1,314 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- Duration 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(DurationUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == DurationUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
deleted file mode 100644
index 7bfb997f2b..0000000000
--- a/UnitsNet.Tests/GeneratedCode/DynamicViscosityTestsBase.g.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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; }
-
-// 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; } }
-// 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);
- }
-
- [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);
- }
-
- [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);
- }
-
- [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);
- }
-
- [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);
- }
-
- [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 EqualsIsImplemented()
- {
- DynamicViscosity 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == DynamicViscosityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
deleted file mode 100644
index 38917b9776..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricAdmittanceTestsBase.g.cs
+++ /dev/null
@@ -1,254 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricAdmittance 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricAdmittanceUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
deleted file mode 100644
index 9e9f244019..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeDensityTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricChargeDensity 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricChargeDensityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
deleted file mode 100644
index eda26be3cb..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricChargeTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 CoulombsInOneCoulomb { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double CoulombsTolerance { 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(CoulombsInOneCoulomb, coulomb.Coulombs, CoulombsTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricCharge.From(1, ElectricChargeUnit.Coulomb).Coulombs, CoulombsTolerance);
- }
-
- [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(CoulombsInOneCoulomb, coulomb.As(ElectricChargeUnit.Coulomb), CoulombsTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var coulomb = ElectricCharge.FromCoulombs(1);
-
- var coulombQuantity = coulomb.ToUnit(ElectricChargeUnit.Coulomb);
- AssertEx.EqualTolerance(CoulombsInOneCoulomb, (double)coulombQuantity.Value, CoulombsTolerance);
- Assert.Equal(ElectricChargeUnit.Coulomb, coulombQuantity.Unit);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricCharge coulomb = ElectricCharge.FromCoulombs(1);
- AssertEx.EqualTolerance(1, ElectricCharge.FromCoulombs(coulomb.Coulombs).Coulombs, CoulombsTolerance);
- }
-
- [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 EqualsIsImplemented()
- {
- ElectricCharge 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricChargeUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
deleted file mode 100644
index 9ed876aeed..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductanceTestsBase.g.cs
+++ /dev/null
@@ -1,244 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricConductance 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricConductanceUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
deleted file mode 100644
index ea049f0f48..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricConductivityTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 SiemensPerMeterInOneSiemensPerMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- 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(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.SiemensPerMeter, SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- 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(SiemensPerMeterInOneSiemensPerMeter, siemenspermeter.As(ElectricConductivityUnit.SiemensPerMeter), SiemensPerMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var siemenspermeter = ElectricConductivity.FromSiemensPerMeter(1);
-
- 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.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 EqualsIsImplemented()
- {
- ElectricConductivity 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricConductivityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
deleted file mode 100644
index dd5e6399ba..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentDensityTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 AmperesPerSquareMeterInOneAmperePerSquareMeter { get; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- 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(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.AmperesPerSquareMeter, AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- 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(AmperesPerSquareMeterInOneAmperePerSquareMeter, amperepersquaremeter.As(ElectricCurrentDensityUnit.AmperePerSquareMeter), AmperesPerSquareMeterTolerance);
- }
-
- [Fact]
- public void ToUnit()
- {
- var amperepersquaremeter = ElectricCurrentDensity.FromAmperesPerSquareMeter(1);
-
- 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.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 EqualsIsImplemented()
- {
- ElectricCurrentDensity 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricCurrentDensityUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
deleted file mode 100644
index fe5682a5fe..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentGradientTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricCurrentGradient 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricCurrentGradientUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
deleted file mode 100644
index 3fd63c38a0..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricCurrentTestsBase.g.cs
+++ /dev/null
@@ -1,294 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricCurrent 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricCurrentUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
deleted file mode 100644
index 3d74928898..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricFieldTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricField 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricFieldUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
deleted file mode 100644
index 0200aec8be..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricInductanceTestsBase.g.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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; }
-
-// ReSharper disable VirtualMemberNeverOverriden.Global
- protected virtual double HenriesTolerance { 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);
- }
-
- [Fact]
- public void FromValueAndUnit()
- {
- AssertEx.EqualTolerance(1, ElectricInductance.From(1, ElectricInductanceUnit.Henry).Henries, HenriesTolerance);
- }
-
- [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);
- }
-
- [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);
- }
-
- [Fact]
- public void ConversionRoundTrip()
- {
- ElectricInductance henry = ElectricInductance.FromHenries(1);
- AssertEx.EqualTolerance(1, ElectricInductance.FromHenries(henry.Henries).Henries, HenriesTolerance);
- }
-
- [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 EqualsIsImplemented()
- {
- ElectricInductance 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricInductanceUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
deleted file mode 100644
index 7b4d02bbcb..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialAcTestsBase.g.cs
+++ /dev/null
@@ -1,264 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 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 GeneratUnits.bat to generate new units or quantities.
-//
-//
-//------------------------------------------------------------------------------
-
-// Copyright (c) 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).
-// https://github.com/angularsen/UnitsNet
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-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 EqualsIsImplemented()
- {
- ElectricPotentialAc 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 AllUnitsHaveAtLeastOneAbbreviationSpecified()
- {
- var units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast();
- foreach(var unit in units)
- {
- if(unit == ElectricPotentialAcUnit.Undefined)
- continue;
-
- var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit);
- }
- }
- }
-}
diff --git a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
deleted file mode 100644
index 35bfbf279b..0000000000
--- a/UnitsNet.Tests/GeneratedCode/ElectricPotentialDcTestsBase.g.cs
+++ /dev/null
@@ -1,264 +0,0 @@
-//------------------------------------------------------------------------------
-//