-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e51cd52
commit 0a585b8
Showing
8 changed files
with
1,426 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated (once) by \generate-code.bat, but will not be | ||
// regenerated when it already exists. The purpose of creating this file is to make | ||
// it easier to remember to implement all the unit conversion test cases. | ||
// | ||
// Whenever a new unit is added to this quantity and \generate-code.bat is run, | ||
// the base test class will get a new abstract property and cause a compile error | ||
// in this derived class, reminding the developer to implement the test case | ||
// for the new unit. | ||
// | ||
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. | ||
// | ||
// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities. | ||
// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior. | ||
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities. | ||
// | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
// Copyright (c) 2007 Andreas Gullberg Larsen ([email protected]). | ||
// 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; | ||
|
||
namespace UnitsNet.Tests.CustomCode | ||
{ | ||
public class MolarEntropyTests : MolarEntropyTestsBase | ||
{ | ||
protected override double JoulesPerMoleKelvinInOneJoulePerMoleKelvin => 1e0; | ||
protected override double KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin => 1e-3; | ||
protected override double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin => 1e-6; | ||
} | ||
} |
191 changes: 191 additions & 0 deletions
191
UnitsNet.Tests/GeneratedCode/MolarEntropyTestsBase.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// 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\MyUnit.extra.cs files to add code to generated quantities. | ||
// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior. | ||
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities. | ||
// | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
// Copyright (c) 2007 Andreas Gullberg Larsen ([email protected]). | ||
// 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 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 | ||
{ | ||
/// <summary> | ||
/// Test of MolarEntropy. | ||
/// </summary> | ||
// ReSharper disable once PartialTypeWithSinglePart | ||
public abstract partial class MolarEntropyTestsBase | ||
{ | ||
protected abstract double JoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } | ||
protected abstract double KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } | ||
protected abstract double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } | ||
|
||
// ReSharper disable VirtualMemberNeverOverriden.Global | ||
protected virtual double JoulesPerMoleKelvinTolerance { get { return 1e-5; } } | ||
protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1e-5; } } | ||
protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } | ||
// ReSharper restore VirtualMemberNeverOverriden.Global | ||
|
||
[Fact] | ||
public void JoulePerMoleKelvinToMolarEntropyUnits() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); | ||
} | ||
|
||
[Fact] | ||
public void FromValueAndUnit() | ||
{ | ||
AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.JoulePerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.KilojoulePerMoleKelvin).KilojoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(1, MolarEntropy.From(1, MolarEntropyUnit.MegajoulePerMoleKelvin).MegajoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); | ||
} | ||
|
||
[Fact] | ||
public void As() | ||
{ | ||
var joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
AssertEx.EqualTolerance(JoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.JoulePerMoleKelvin), JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(KilojoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.KilojoulePerMoleKelvin), KilojoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin, joulepermolekelvin.As(MolarEntropyUnit.MegajoulePerMoleKelvin), MegajoulesPerMoleKelvinTolerance); | ||
} | ||
|
||
[Fact] | ||
public void ConversionRoundTrip() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
AssertEx.EqualTolerance(1, MolarEntropy.FromJoulesPerMoleKelvin(joulepermolekelvin.JoulesPerMoleKelvin).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(1, MolarEntropy.FromKilojoulesPerMoleKelvin(joulepermolekelvin.KilojoulesPerMoleKelvin).JoulesPerMoleKelvin, KilojoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(1, MolarEntropy.FromMegajoulesPerMoleKelvin(joulepermolekelvin.MegajoulesPerMoleKelvin).JoulesPerMoleKelvin, MegajoulesPerMoleKelvinTolerance); | ||
} | ||
|
||
[Fact] | ||
public void ArithmeticOperators() | ||
{ | ||
MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
AssertEx.EqualTolerance(-1, -v.JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(3)-v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(2, (v + v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(10, (v*10).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(10, (10*v).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(2, (MolarEntropy.FromJoulesPerMoleKelvin(10)/5).JoulesPerMoleKelvin, JoulesPerMoleKelvinTolerance); | ||
AssertEx.EqualTolerance(2, MolarEntropy.FromJoulesPerMoleKelvin(10)/MolarEntropy.FromJoulesPerMoleKelvin(5), JoulesPerMoleKelvinTolerance); | ||
} | ||
|
||
[Fact] | ||
public void ComparisonOperators() | ||
{ | ||
MolarEntropy oneJoulePerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
MolarEntropy twoJoulesPerMoleKelvin = MolarEntropy.FromJoulesPerMoleKelvin(2); | ||
|
||
Assert.True(oneJoulePerMoleKelvin < twoJoulesPerMoleKelvin); | ||
Assert.True(oneJoulePerMoleKelvin <= twoJoulesPerMoleKelvin); | ||
Assert.True(twoJoulesPerMoleKelvin > oneJoulePerMoleKelvin); | ||
Assert.True(twoJoulesPerMoleKelvin >= oneJoulePerMoleKelvin); | ||
|
||
Assert.False(oneJoulePerMoleKelvin > twoJoulesPerMoleKelvin); | ||
Assert.False(oneJoulePerMoleKelvin >= twoJoulesPerMoleKelvin); | ||
Assert.False(twoJoulesPerMoleKelvin < oneJoulePerMoleKelvin); | ||
Assert.False(twoJoulesPerMoleKelvin <= oneJoulePerMoleKelvin); | ||
} | ||
|
||
[Fact] | ||
public void CompareToIsImplemented() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.Equal(0, joulepermolekelvin.CompareTo(joulepermolekelvin)); | ||
Assert.True(joulepermolekelvin.CompareTo(MolarEntropy.Zero) > 0); | ||
Assert.True(MolarEntropy.Zero.CompareTo(joulepermolekelvin) < 0); | ||
} | ||
|
||
[Fact] | ||
public void CompareToThrowsOnTypeMismatch() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.Throws<ArgumentException>(() => joulepermolekelvin.CompareTo(new object())); | ||
} | ||
|
||
[Fact] | ||
public void CompareToThrowsOnNull() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.Throws<ArgumentNullException>(() => joulepermolekelvin.CompareTo(null)); | ||
} | ||
|
||
|
||
[Fact] | ||
public void EqualityOperators() | ||
{ | ||
MolarEntropy a = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
MolarEntropy b = MolarEntropy.FromJoulesPerMoleKelvin(2); | ||
|
||
// ReSharper disable EqualExpressionComparison | ||
Assert.True(a == a); | ||
Assert.True(a != b); | ||
|
||
Assert.False(a == b); | ||
Assert.False(a != a); | ||
// ReSharper restore EqualExpressionComparison | ||
} | ||
|
||
[Fact] | ||
public void EqualsIsImplemented() | ||
{ | ||
MolarEntropy v = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.True(v.Equals(MolarEntropy.FromJoulesPerMoleKelvin(1))); | ||
Assert.False(v.Equals(MolarEntropy.Zero)); | ||
} | ||
|
||
[Fact] | ||
public void EqualsReturnsFalseOnTypeMismatch() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.False(joulepermolekelvin.Equals(new object())); | ||
} | ||
|
||
[Fact] | ||
public void EqualsReturnsFalseOnNull() | ||
{ | ||
MolarEntropy joulepermolekelvin = MolarEntropy.FromJoulesPerMoleKelvin(1); | ||
Assert.False(joulepermolekelvin.Equals(null)); | ||
} | ||
} | ||
} |
Oops, something went wrong.