startit/Emne 3/Calc/Calculator.Test/UnitTest1.cs
Geir Okkenhaug Jerstad 5b6d47da85 mer unit test
2025-01-03 13:23:45 +01:00

43 lines
937 B
C#

namespace Calculator.Test;
public class Tests
{
[Test]
public void TestLeggSammen()
{
var calc = new Calc.Calculator();
var sum = calc.LeggSammen(1, 2);
Assert.That(sum, Is.EqualTo(3));
}
[Test]
public void TestTrekkFra()
{
var calc = new Calc.Calculator();
var sum = calc.TrekkFra(2, 1);
Assert.That(sum, Is.EqualTo(1));
}
[Test]
public void TestMultipliser()
{
var calc = new Calc.Calculator();
var sum = calc.Multipliser(2, 2);
Assert.That(sum, Is.EqualTo(4));
}
[Test]
public void TestDivision()
{
var calc = new Calc.Calculator();
var sum = calc.Divider(4, 2);
Assert.That(sum, Is.EqualTo(2));
}
[Test]
public void TestDivisionByZero()
{
var calc = new Calc.Calculator();
Assert.Throws<ArgumentException>(() => calc.Divider(4, 0));
}
}