startit/Emne 3/UnitTesting/UnitTesting.Test/UnitTest1.cs

34 lines
759 B
C#
Raw Permalink Normal View History

2025-01-02 13:09:14 +01:00
namespace UnitTesting.Test;
public class StatsTest
{
[Test]
public void TestWith3And4()
{
2025-01-02 14:41:32 +01:00
// arrange
2025-01-02 13:09:14 +01:00
var stats = new Stats();
2025-01-02 14:41:32 +01:00
//act
stats.Add(3);
stats.Add(4);
// assert
Assert.AreEqual(2, stats.Count);
Assert.AreEqual(7, stats.Sum);
Assert.AreEqual(4, stats.Max);
Assert.AreEqual(3, stats.Min);
Assert.AreEqual(3.5, stats.Mean, 0.0001);
}
[Test]
public void TestEmptyStats()
{
var stats = new Stats();
Assert.AreEqual(0, stats.Count);
Assert.AreEqual(0, stats.Sum);
Assert.IsNull(stats.Max);
Assert.IsNull(stats.Min);
Assert.AreEqual(float.NaN, stats.Mean);
2025-01-02 13:09:14 +01:00
}
}