Skip to content

Instantly share code, notes, and snippets.

@fffej fffej/Kata2.cs
Created Mar 28, 2017

Embed
What would you like to do?
Kata number 2
namespace TDDKata2
{
public class Class1
{
[Test]
public void Volume_Of_A_Cube()
{
Assert.That(new Cube(1).Volume, Is.EqualTo(1));
}
[Test]
public void Volume_of_a_Cylinder()
{
Assert.That(Cylinder.GetVolume(1, 1), Is.EqualTo(Math.PI));
Assert.That(Cylinder.GetVolume(2, 1), Is.EqualTo(2 * Math.PI));
}
[Test]
public void Volume_of_a_Pyramid()
{
Assert.That(Volume.Of(new Pyramid(1, 1)), Is.EqualTo(1.0/3));
}
}
public static class Cylinder
{
public static double GetVolume(int height, int radius)
{
return Math.PI * radius * radius * height;
}
}
public class Cube
{
private readonly int _width;
public Cube(int width)
{
_width = width;
}
public double Volume => _width * _width * _width;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.