Part 1 & 2

This commit is contained in:
KäseToatz
2024-09-25 22:24:42 +02:00
commit a33cf50a4c
14 changed files with 382 additions and 0 deletions

View File

@ -0,0 +1,62 @@
using Buckets.Logic;
namespace Buckets.Test
{
[TestClass]
public class BucketTest
{
[TestMethod]
public void Bucket_DefaultCapacity_ShouldEqual12()
{
Bucket bucket = new(0);
Assert.AreEqual(12, bucket.Capacity);
}
[TestMethod]
public void Bucket_LowCapacity_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket bucket = new(5, 0);
});
}
[TestMethod]
public void Bucket_HighCapacity_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket bucket = new(2501, 0);
});
}
[TestMethod]
public void Fill_BucketOverCapacity_ShouldThrow()
{
Bucket bucket = new(10, 0);
Bucket bucket2 = new(20, 20);
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
bucket.Fill(bucket2);
});
}
[TestMethod]
public void Fill_SecondBucket_ShouldEqual0()
{
Bucket bucket = new(20, 0);
Bucket bucket2 = new(20, 10);
bucket.Fill(bucket2);
Assert.AreEqual(0, bucket2.Content);
}
[TestMethod]
public void Fill_Bucket_ShouldEqual20()
{
Bucket bucket = new(20, 10);
Bucket bucket2 = new(20, 10);
bucket.Fill(bucket2);
Assert.AreEqual(20, bucket.Content);
}
}
}