Skip to content

Instantly share code, notes, and snippets.

@erikdietrich
Created November 8, 2012 20:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save erikdietrich/4041227 to your computer and use it in GitHub Desktop.
The frame's test class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ScratchPadTest
{
[TestClass]
public class FrameTest
{
[TestClass]
public class Constructor
{
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Initializes_FirstThrow_To_Passed_In_Value()
{
var frame = new Frame(1, 0);
Assert.AreEqual<int>(1, frame.FirstThrow);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Initializes_SecondThrow_To_Passed_In_Value()
{
var frame = new Frame(0, 1);
Assert.AreEqual<int>(1, frame.SecondThrow);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_Negative_Argument()
{
ExtendedAssert.Throws<Frame.UnderflowException>(() => new Frame(-1, 0));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_Score_Of_11()
{
ExtendedAssert.Throws<Frame.OverflowException>(() => new Frame(10, 1));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Initializes_Total_To_FirstThrow_Plus_SecondThrow()
{
const int firstThrow = 4;
const int secondThrow = 3;
Assert.AreEqual<int>(firstThrow + secondThrow, new Frame(firstThrow, secondThrow).Total);
}
}
[TestClass]
public class IsStrike
{
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_True_When_Frame_Has_10_For_First_Throw()
{
var frame = Frame.Strike;
Assert.IsTrue(frame.IsStrike);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_False_When_Frame_Does_Not_Have_10_For_First_Throw()
{
var frame = new Frame(0, 2);
Assert.IsFalse(frame.IsStrike);
}
}
[TestClass]
public class IsSpare
{
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_True_When_Frame_Totals_Mark()
{
var frame = new Frame(4, 6);
Assert.IsTrue(frame.IsSpare);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_False_When_Frame_Does_Not_Total_10()
{
var frame = new Frame(0, 9);
Assert.IsFalse(frame.IsSpare);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_False_When_Frame_Is_Strike()
{
var frame = Frame.Strike;
Assert.IsFalse(frame.IsSpare);
}
}
[TestClass]
public class Strike
{
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Returns_Frame_With_Is_Strike_True()
{
Assert.IsTrue(Frame.Strike.IsStrike);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment