Added Unit Tests
This commit is contained in:
46
Tests/HelpersUtilsTest.cs
Normal file
46
Tests/HelpersUtilsTest.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Elwig.Helpers;
|
||||
|
||||
namespace Tests {
|
||||
[TestClass]
|
||||
public class HelpersUtilsTest {
|
||||
|
||||
private static readonly double[,] Gradation = new double[,] {
|
||||
{ 14.0, 68.0 },
|
||||
{ 15.0, 73.0 },
|
||||
{ 17.1, 84.0 },
|
||||
{ 19.0, 94.0 },
|
||||
{ 21.0, 105.0 },
|
||||
{ 25.0, 127.0 },
|
||||
{ 27.1, 139.0 },
|
||||
{ 30.0, 156.0 },
|
||||
};
|
||||
|
||||
[TestMethod]
|
||||
public void Test_KmwToOe() {
|
||||
for (int i = 0; i < Gradation.GetLength(0); i++) {
|
||||
Assert.AreEqual(Gradation[i, 1], Utils.KmwToOe(Gradation[i, 0]));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Test_OeToKmw() {
|
||||
for (int i = 0; i < Gradation.GetLength(0); i++) {
|
||||
Assert.AreEqual(Gradation[i, 0], Utils.OeToKmw(Gradation[i, 1]));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Test_DecFromDb() {
|
||||
Assert.AreEqual(10.67M, Utils.DecFromDb(10670, 3));
|
||||
Assert.AreEqual(-100.9999M, Utils.DecFromDb(-1009999, 4));
|
||||
Assert.AreEqual(0.01M, Utils.DecFromDb(1, 2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Test_DecToDb() {
|
||||
Assert.AreEqual(21948, Utils.DecToDb(219.48M, 2));
|
||||
Assert.AreEqual(-12345, Utils.DecToDb(-1.2345M, 4));
|
||||
Assert.AreEqual(99190, Utils.DecToDb(99190, 0));
|
||||
}
|
||||
}
|
||||
}
|
23
Tests/Tests.csproj
Normal file
23
Tests/Tests.csproj
Normal file
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Elwig\Elwig.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
1
Tests/Usings.cs
Normal file
1
Tests/Usings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
Reference in New Issue
Block a user