Part 1 & 2
This commit is contained in:
62
Buckets.Test/BucketTest.cs
Normal file
62
Buckets.Test/BucketTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
27
Buckets.Test/Buckets.Test.csproj
Normal file
27
Buckets.Test/Buckets.Test.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Buckets.Logic\Buckets.Logic.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
86
Buckets.Test/ContainerTest.cs
Normal file
86
Buckets.Test/ContainerTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
15
Buckets.Test/OilBarrelTest.cs
Normal file
15
Buckets.Test/OilBarrelTest.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Buckets.Logic;
|
||||
|
||||
namespace Buckets.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class OilBarrelTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void OilBarrel_ValidParams_ShouldEqualDefault()
|
||||
{
|
||||
OilBarrel oilbarrel = new(10);
|
||||
Assert.AreEqual(OilBarrel.CAPACITY, oilbarrel.Capacity);
|
||||
}
|
||||
}
|
||||
}
|
24
Buckets.Test/RainBarrelTest.cs
Normal file
24
Buckets.Test/RainBarrelTest.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Buckets.Logic;
|
||||
|
||||
namespace Buckets.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class RainBarrelTest
|
||||
{
|
||||
[TestMethod]
|
||||
public void RainBarrel_DisallowedCapacity_ShouldThrow()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentException>(() =>
|
||||
{
|
||||
Rainbarrel rainbarrel = new(90, 0);
|
||||
});
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void RainBarrel_AllowedCapacity_ShouldEqual100()
|
||||
{
|
||||
Rainbarrel rainbarrel = new(100, 0);
|
||||
Assert.AreEqual(100, rainbarrel.Capacity);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user