-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
7fb4715
commit 460c887
Showing
5 changed files
with
93 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
28 changes: 28 additions & 0 deletions
28
Tests/ChemSharp.UnitConversion.Tests/ChemSharp.UnitConversion.Tests.csproj
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,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.5.1"/> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/> | ||
<PackageReference Include="xunit" Version="2.4.1"/> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\ChemSharp.UnitConversion\ChemSharp.UnitConversion.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
23 changes: 23 additions & 0 deletions
23
Tests/ChemSharp.UnitConversion.Tests/EnergyConversionTests.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,23 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace ChemSharp.UnitConversion.Tests; | ||
|
||
public class EnergyConversionTests | ||
{ | ||
[Fact] | ||
public void ElectronVolt_To_Wavenumbers() | ||
{ | ||
var converter = new EnergyUnitConverter("eV", "cm^-1"); | ||
converter.Convert(1).Should().BeApproximately(8065.544, 5e-4); | ||
converter.ConvertInverted(1).Should().BeApproximately(1 / 8065.544, 5e-4); | ||
} | ||
|
||
[Fact] | ||
public void Nanometers_To_Wavenumbers() | ||
{ | ||
var converter = new EnergyUnitConverter("nm", "cm^-1"); | ||
converter.Convert(500).Should().Be(20000); | ||
converter.ConvertInverted(20000).Should().Be(500); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Tests/ChemSharp.UnitConversion.Tests/MagneticConversionTests.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,14 @@ | ||
using Xunit; | ||
|
||
namespace ChemSharp.UnitConversion.Tests; | ||
|
||
public class MagneticConversionTests | ||
{ | ||
[Fact] | ||
public void Gauss_To_Millitesla() | ||
{ | ||
var converter = new MagneticUnitConverter("G", "mT"); | ||
Assert.Equal(.1, converter.Convert(1)); | ||
Assert.Equal(10, converter.ConvertInverted(1)); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Tests/ChemSharp.UnitConversion.Tests/MassConversionTests.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,21 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace ChemSharp.UnitConversion.Tests; | ||
|
||
public class MassConversionTests | ||
{ | ||
[Fact] | ||
public void SolarMass_To_EarthMass() | ||
{ | ||
var converter = new MassUnitConverter("Solar Mass", "Earth Mass"); | ||
converter.Convert(1).Should().BeApproximately(332946.0487, 1.5); | ||
} | ||
|
||
[Fact] | ||
public void Lbs_to_g() | ||
{ | ||
var converter = new MassUnitConverter("lbs", "g"); | ||
converter.Convert(1).Should().Be(453.59237); | ||
} | ||
} |