Adhere to NUnit guidelines

This commit is contained in:
2023-04-26 22:17:07 +02:00
parent 6acdbee154
commit 0365669ea2
2 changed files with 42 additions and 30 deletions

View File

@ -17,46 +17,56 @@ namespace Tests {
[Test] [Test]
public void Test_KmwToOe() { public void Test_KmwToOe() {
Assert.Multiple(() => {
for (int i = 0; i < Gradation.GetLength(0); i++) { for (int i = 0; i < Gradation.GetLength(0); i++) {
Assert.AreEqual(Gradation[i, 1], Utils.KmwToOe(Gradation[i, 0])); Assert.That(Utils.KmwToOe(Gradation[i, 0]), Is.EqualTo(Gradation[i, 1]));
} }
});
} }
[Test] [Test]
public void Test_OeToKmw() { public void Test_OeToKmw() {
Assert.Multiple(() => {
for (int i = 0; i < Gradation.GetLength(0); i++) { for (int i = 0; i < Gradation.GetLength(0); i++) {
Assert.AreEqual(Gradation[i, 0], Utils.OeToKmw(Gradation[i, 1])); Assert.That(Utils.OeToKmw(Gradation[i, 1]), Is.EqualTo(Gradation[i, 0]));
} }
});
} }
[Test] [Test]
public void Test_DecFromDb() { public void Test_DecFromDb() {
Assert.AreEqual(10.67M, Utils.DecFromDb(10670, 3)); Assert.Multiple(() => {
Assert.AreEqual(-100.9999M, Utils.DecFromDb(-1009999, 4)); Assert.That(Utils.DecFromDb(10670, 3), Is.EqualTo(10.67M));
Assert.AreEqual(0.01M, Utils.DecFromDb(1, 2)); Assert.That(Utils.DecFromDb(-1009999, 4), Is.EqualTo(-100.9999M));
Assert.That(Utils.DecFromDb(1, 2), Is.EqualTo(0.01M));
});
} }
[Test] [Test]
public void Test_DecToDb() { public void Test_DecToDb() {
Assert.AreEqual(21948, Utils.DecToDb(219.48M, 2)); Assert.Multiple(() => {
Assert.AreEqual(-12345, Utils.DecToDb(-1.2345M, 4)); Assert.That(Utils.DecToDb(219.48M, 2), Is.EqualTo(21948));
Assert.AreEqual(99190, Utils.DecToDb(99190, 0)); Assert.That(Utils.DecToDb(-1.2345M, 4), Is.EqualTo(-12345));
Assert.AreEqual(817910, Utils.DecToDb(817.9099M, 3)); Assert.That(Utils.DecToDb(99190, 0), Is.EqualTo(99190));
Assert.AreEqual(-561894, Utils.DecToDb(-5618.944M, 2)); Assert.That(Utils.DecToDb(817.9099M, 3), Is.EqualTo(817910));
Assert.That(Utils.DecToDb(-5618.944M, 2), Is.EqualTo(-561894));
});
} }
[Test] [Test]
public void Test_Modulo() { public void Test_Modulo() {
Assert.AreEqual(1, Utils.Modulo("1", 2)); Assert.Multiple(() => {
Assert.AreEqual(1, Utils.Modulo("12", 11)); Assert.That(Utils.Modulo("1", 2), Is.EqualTo(1));
Assert.AreEqual(1, Utils.Modulo("65", 16)); Assert.That(Utils.Modulo("12", 11), Is.EqualTo(1));
Assert.AreEqual(4, Utils.Modulo("91746381048364", 10)); Assert.That(Utils.Modulo("65", 16), Is.EqualTo(1));
Assert.AreEqual(1, Utils.Modulo("210501700012345678131468", 97)); Assert.That(Utils.Modulo("91746381048364", 10), Is.EqualTo(4));
Assert.That(Utils.Modulo("210501700012345678131468", 97), Is.EqualTo(1));
Assert.Throws<ArgumentException>(() => Utils.Modulo("", 4)); Assert.Throws<ArgumentException>(() => Utils.Modulo("", 4));
Assert.Throws<ArgumentException>(() => Utils.Modulo("1ab", 5)); Assert.Throws<ArgumentException>(() => Utils.Modulo("1ab", 5));
Assert.Throws<ArgumentException>(() => Utils.Modulo("123", 1)); Assert.Throws<ArgumentException>(() => Utils.Modulo("123", 1));
Assert.Throws<ArgumentException>(() => Utils.Modulo("456", 0)); Assert.Throws<ArgumentException>(() => Utils.Modulo("456", 0));
Assert.Throws<ArgumentException>(() => Utils.Modulo("789", -1)); Assert.Throws<ArgumentException>(() => Utils.Modulo("789", -1));
});
} }
} }
} }

View File

@ -15,12 +15,14 @@ namespace Tests {
[Test] [Test]
public void Test_CheckInteger_Simple() { public void Test_CheckInteger_Simple() {
Assert.IsFalse(Validator.CheckInteger(CreateTextBox(""), true).IsValid); Assert.Multiple(() => {
Assert.IsTrue(Validator.CheckInteger(CreateTextBox(""), false).IsValid); Assert.That(Validator.CheckInteger(CreateTextBox(""), true).IsValid, Is.False);
Assert.IsTrue(Validator.CheckInteger(CreateTextBox("123"), true).IsValid); Assert.That(Validator.CheckInteger(CreateTextBox(""), false).IsValid, Is.True);
Assert.IsTrue(Validator.CheckInteger(CreateTextBox("456"), false).IsValid); Assert.That(Validator.CheckInteger(CreateTextBox("123"), true).IsValid, Is.True);
Assert.IsTrue(Validator.CheckInteger(CreateTextBox("1234"), false, 4).IsValid); Assert.That(Validator.CheckInteger(CreateTextBox("456"), false).IsValid, Is.True);
Assert.IsTrue(Validator.CheckInteger(CreateTextBox("4567"), false, 3).IsValid); Assert.That(Validator.CheckInteger(CreateTextBox("1234"), false, 4).IsValid, Is.True);
Assert.That(Validator.CheckInteger(CreateTextBox("4567"), false, 3).IsValid, Is.True);
});
} }
} }
} }