|
| 1 | +//------------------------------------------------------------------------------ |
| 2 | +// <auto-generated> |
| 3 | +// This code was generated by \generate-code.bat. |
| 4 | +// |
| 5 | +// Changes to this file will be lost when the code is regenerated. |
| 6 | +// The build server regenerates the code before each build and a pre-build |
| 7 | +// step will regenerate the code on each local build. |
| 8 | +// |
| 9 | +// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. |
| 10 | +// |
| 11 | +// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities. |
| 12 | +// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior. |
| 13 | +// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities. |
| 14 | +// |
| 15 | +// </auto-generated> |
| 16 | +//------------------------------------------------------------------------------ |
| 17 | + |
| 18 | +// Copyright (c) 2007 Andreas Gullberg Larsen ([email protected]). |
| 19 | +// https://github.com/angularsen/UnitsNet |
| 20 | +// |
| 21 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 22 | +// of this software and associated documentation files (the "Software"), to deal |
| 23 | +// in the Software without restriction, including without limitation the rights |
| 24 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 25 | +// copies of the Software, and to permit persons to whom the Software is |
| 26 | +// furnished to do so, subject to the following conditions: |
| 27 | +// |
| 28 | +// The above copyright notice and this permission notice shall be included in |
| 29 | +// all copies or substantial portions of the Software. |
| 30 | +// |
| 31 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 32 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 33 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 34 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 35 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 36 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 37 | +// THE SOFTWARE. |
| 38 | + |
| 39 | +using System; |
| 40 | +using UnitsNet.Units; |
| 41 | +using Xunit; |
| 42 | + |
| 43 | +// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else? |
| 44 | +#pragma warning disable 1718 |
| 45 | + |
| 46 | +// ReSharper disable once CheckNamespace |
| 47 | +namespace UnitsNet.Tests |
| 48 | +{ |
| 49 | + /// <summary> |
| 50 | + /// Test of MolarEntropy. |
| 51 | + /// </summary> |
| 52 | +// ReSharper disable once PartialTypeWithSinglePart |
| 53 | + public abstract partial class MolarEntropyTestsBase |
| 54 | + { |
| 55 | + protected abstract double JoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } |
| 56 | + protected abstract double KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } |
| 57 | + protected abstract double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } |
| 58 | + |
| 59 | +// ReSharper disable VirtualMemberNeverOverriden.Global |
| 60 | + protected virtual double JoulesPerMoleKelvinTolerance { get { return 1e-5; } } |
| 61 | + protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1e-5; } } |
| 62 | + protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } |
| 63 | +// ReSharper restore VirtualMemberNeverOverriden.Global |
| 64 | + |
| 65 | + [Fact] |
| 66 | + public void JoulePerMoleKelvinToMolarEntropyUnits() |
| 67 | + { |
| 68 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 69 | + AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 70 | + AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); |
| 71 | + AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); |
| 72 | + } |
| 73 | + |
| 74 | + [Fact] |
| 75 | + public void FromValueAndUnit() |
| 76 | + { |
| 77 | + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.JoulePerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 78 | + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.KilojoulePerMoleKelvin).KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); |
| 79 | + AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.MegajoulePerMoleKelvin).MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); |
| 80 | + } |
| 81 | + |
| 82 | + [Fact] |
| 83 | + public void As() |
| 84 | + { |
| 85 | + var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 86 | + AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.JoulePerMoleKelvin), JoulesPerMoleKelvinTolerance); |
| 87 | + AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.KilojoulePerMoleKelvin), KilojoulesPerMoleKelvinTolerance); |
| 88 | + AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.MegajoulePerMoleKelvin), MegajoulesPerMoleKelvinTolerance); |
| 89 | + } |
| 90 | + |
| 91 | + [Fact] |
| 92 | + public void ConversionRoundTrip() |
| 93 | + { |
| 94 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 95 | + AssertEx.EqualTolerance(1, MolarEntropy.FromJoulesPerMoleKelvin(joulepermolekelvin.JoulesPerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 96 | + AssertEx.EqualTolerance(1, MolarEntropy.FromKilojoulesPerMoleKelvin(joulepermolekelvin.KilojoulesPerMoleKelvin).JoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); |
| 97 | + AssertEx.EqualTolerance(1, MolarEntropy.FromMegajoulesPerMoleKelvin(joulepermolekelvin.MegajoulesPerMoleKelvin).JoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); |
| 98 | + } |
| 99 | + |
| 100 | + [Fact] |
| 101 | + public void ArithmeticOperators() |
| 102 | + { |
| 103 | + MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 104 | + AssertEx.EqualTolerance(-1, -v.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 105 | + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(3)-v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 106 | + AssertEx.EqualTolerance(2, (v + v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 107 | + AssertEx.EqualTolerance(10, (v*10).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 108 | + AssertEx.EqualTolerance(10, (10*v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 109 | + AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(10)/5).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); |
| 110 | + AssertEx.EqualTolerance(2, MolarEntropy.FromJoulesPerMoleKelvin(10)/MolarEntropy.FromJoulesPerMoleKelvin(5), JoulesPerMoleKelvinTolerance); |
| 111 | + } |
| 112 | + |
| 113 | + [Fact] |
| 114 | + public void ComparisonOperators() |
| 115 | + { |
| 116 | + MolarEntropy oneJoulePerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 117 | + MolarEntropy twoJoulesPerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(2); |
| 118 | + |
| 119 | + Assert.True(oneJoulePerMoleKelvin < twoJoulesPerMoleKelvin); |
| 120 | + Assert.True(oneJoulePerMoleKelvin <= twoJoulesPerMoleKelvin); |
| 121 | + Assert.True(twoJoulesPerMoleKelvin > oneJoulePerMoleKelvin); |
| 122 | + Assert.True(twoJoulesPerMoleKelvin >= oneJoulePerMoleKelvin); |
| 123 | + |
| 124 | + Assert.False(oneJoulePerMoleKelvin > twoJoulesPerMoleKelvin); |
| 125 | + Assert.False(oneJoulePerMoleKelvin >= twoJoulesPerMoleKelvin); |
| 126 | + Assert.False(twoJoulesPerMoleKelvin < oneJoulePerMoleKelvin); |
| 127 | + Assert.False(twoJoulesPerMoleKelvin <= oneJoulePerMoleKelvin); |
| 128 | + } |
| 129 | + |
| 130 | + [Fact] |
| 131 | + public void CompareToIsImplemented() |
| 132 | + { |
| 133 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 134 | + Assert.Equal(0, joulepermolekelvin.CompareTo(joulepermolekelvin)); |
| 135 | + Assert.True(joulepermolekelvin.CompareTo(MolarEntropy.Zero) > 0); |
| 136 | + Assert.True(MolarEntropy.Zero.CompareTo(joulepermolekelvin) < 0); |
| 137 | + } |
| 138 | + |
| 139 | + [Fact] |
| 140 | + public void CompareToThrowsOnTypeMismatch() |
| 141 | + { |
| 142 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 143 | + Assert.Throws<ArgumentException>(() => joulepermolekelvin.CompareTo(new object())); |
| 144 | + } |
| 145 | + |
| 146 | + [Fact] |
| 147 | + public void CompareToThrowsOnNull() |
| 148 | + { |
| 149 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 150 | + Assert.Throws<ArgumentNullException>(() => joulepermolekelvin.CompareTo(null)); |
| 151 | + } |
| 152 | + |
| 153 | + |
| 154 | + [Fact] |
| 155 | + public void EqualityOperators() |
| 156 | + { |
| 157 | + MolarEntropy a = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 158 | + MolarEntropy b = MolarEntropy.FromJoulesPerMoleKelvin(2); |
| 159 | + |
| 160 | +// ReSharper disable EqualExpressionComparison |
| 161 | + Assert.True(a == a); |
| 162 | + Assert.True(a != b); |
| 163 | + |
| 164 | + Assert.False(a == b); |
| 165 | + Assert.False(a != a); |
| 166 | +// ReSharper restore EqualExpressionComparison |
| 167 | + } |
| 168 | + |
| 169 | + [Fact] |
| 170 | + public void EqualsIsImplemented() |
| 171 | + { |
| 172 | + MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 173 | + Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1))); |
| 174 | + Assert.False(v.Equals(MolarEntropy.Zero)); |
| 175 | + } |
| 176 | + |
| 177 | + [Fact] |
| 178 | + public void EqualsReturnsFalseOnTypeMismatch() |
| 179 | + { |
| 180 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 181 | + Assert.False(joulepermolekelvin.Equals(new object())); |
| 182 | + } |
| 183 | + |
| 184 | + [Fact] |
| 185 | + public void EqualsReturnsFalseOnNull() |
| 186 | + { |
| 187 | + MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); |
| 188 | + Assert.False(joulepermolekelvin.Equals(null)); |
| 189 | + } |
| 190 | + } |
| 191 | +} |
0 commit comments