Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fffej
Created March 28, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fffej/10ca04b04a94805c3700ea67413356f3 to your computer and use it in GitHub Desktop.
Save fffej/10ca04b04a94805c3700ea67413356f3 to your computer and use it in GitHub Desktop.
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