added events

This commit is contained in:
KaseToatz1337
2024-10-03 09:16:40 +02:00
parent a33cf50a4c
commit d3de812339
5 changed files with 57 additions and 31 deletions

View File

@ -30,17 +30,6 @@ namespace Buckets.Test
});
}
[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()
{

View File

@ -23,15 +23,6 @@ namespace Buckets.Test
});
}
[TestMethod]
public void Container_ContentLargerThanCapacity_ShouldThrow()
{
Assert.ThrowsException<ArgumentOutOfRangeException>(() =>
{
Bucket container = new(0, 1);
});
}
[TestMethod]
public void Container_ValidParameters_ShouldEqual10()
{
@ -39,16 +30,6 @@ namespace Buckets.Test
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()
{

28
Buckets.Test/EventTest.cs Normal file
View File

@ -0,0 +1,28 @@
using Buckets.Logic;
namespace Buckets.Test
{
[TestClass]
public class EventTest
{
[TestMethod]
public void FullEvent()
{
Bucket bucket = new(200, 100);
bool didRun = false;
bucket.Full += (Container container, EventArgs eventArgs) => didRun = true;
bucket.Fill(100);
Assert.IsTrue(didRun);
}
[TestMethod]
public void OverflowEvent()
{
Bucket bucket = new(200, 100);
int overflow = 0;
bucket.Overflowed += (Container container, OverflowEventArgs eventArgs) => overflow = eventArgs.OverflowAmount;
bucket.Fill(200);
Assert.AreEqual(100, overflow);
}
}
}