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,86 @@
using Buckets.Logic;
namespace Buckets.Test
{
[TestClass]
public class ContainerTest
{
[TestMethod]
public void Container_NegativeCapacity_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket container = new(-1, 0);
});
}
[TestMethod]
public void Container_NegativeContent_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket container = new(0, -1);
});
}
[TestMethod]
public void Container_ContentLargerThanCapacity_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket container = new(0, 1);
});
}
[TestMethod]
public void Container_ValidParameters_ShouldEqual10()
{
Bucket container = new(20, 10);
Assert.AreEqual(10, container.Content);
}
[TestMethod]
public void Fill_ContentLargerThanCapacity_ShouldThrow()
{
Bucket container = new(20, 10);
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
container.Fill(20);
});
}
[TestMethod]
public void Fill_ValidParameters_ShouldEqual15()
{
Bucket container = new(20, 10);
container.Fill(5);
Assert.AreEqual(15, container.Content);
}
[TestMethod]
public void Empty_NegativeContent_ShouldThrow()
{
Bucket container = new(20, 10);
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
container.Empty(20);
});
}
[TestMethod]
public void Empty_ValidParameters_ShouldEqual5()
{
Bucket container = new(20, 10);
container.Empty(5);
Assert.AreEqual(5, container.Content);
}
[TestMethod]
public void Empty_ValidParameters_ShouldEqual0()
{
Bucket container = new(20, 10);
container.Empty();
Assert.AreEqual(0, container.Content);
}
}
}