From 19b899b5575816117815e5dd9e359c4dcf294933 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Fri, 3 Jan 2025 13:34:56 +0100 Subject: [PATCH] addded test for negative numbers --- Emne 3/Calc/Calculator.Test/UnitTest1.cs | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Emne 3/Calc/Calculator.Test/UnitTest1.cs b/Emne 3/Calc/Calculator.Test/UnitTest1.cs index 7a5ad80..7d1f67a 100644 --- a/Emne 3/Calc/Calculator.Test/UnitTest1.cs +++ b/Emne 3/Calc/Calculator.Test/UnitTest1.cs @@ -8,6 +8,14 @@ public class Tests var calc = new Calc.Calculator(); var sum = calc.LeggSammen(1, 2); Assert.That(sum, Is.EqualTo(3)); + + } + [Test] + public void TestLeggSammenNetgativ() + { + var calc = new Calc.Calculator(); + var sum = calc.LeggSammen(-1, 2); + Assert.That(sum, Is.EqualTo(1)); } [Test] @@ -17,7 +25,13 @@ public class Tests var sum = calc.TrekkFra(2, 1); Assert.That(sum, Is.EqualTo(1)); } - + [Test] + public void TestTrekkFraNetgativ() + { + var calc = new Calc.Calculator(); + var sum = calc.TrekkFra(1, -2); + Assert.That(sum, Is.EqualTo(3)); + } [Test] public void TestMultipliser() { @@ -25,6 +39,13 @@ public class Tests var sum = calc.Multipliser(2, 2); Assert.That(sum, Is.EqualTo(4)); } + [Test] + public void TestMultipliserNegativ() + { + var calc = new Calc.Calculator(); + var sum = calc.Multipliser(3, -3); + Assert.That(sum, Is.EqualTo(-9)); + } [Test] public void TestDivision() @@ -33,7 +54,13 @@ public class Tests var sum = calc.Divider(4, 2); Assert.That(sum, Is.EqualTo(2)); } - + [Test] + public void TestDivisionNegative() + { + var calc = new Calc.Calculator(); + var sum = calc.Divider(4, -2); + Assert.That(sum, Is.EqualTo(-2)); + } [Test] public void TestDivisionByZero() {