Files
elwig/Tests/HelpersUtilsTest.cs
2023-04-20 16:56:41 +02:00

46 lines
1.4 KiB
C#

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));
}
}
}