Skip to content

Instantly share code, notes, and snippets.

@erikdietrich
Created November 8, 2012 20:12
  • 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/4041242 to your computer and use it in GitHub Desktop.
The test class for tenth frame
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 TenthFrameTest
{
[TestClass]
public class Constructor
{
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Initializes_Total_To_Sum_Of_Three_Throws()
{
const int firstThrow = 1;
const int secondThrow = 2;
const int thirdThrow = 0;
var frame = new TenthFrame(firstThrow, secondThrow, thirdThrow);
Assert.AreEqual<int>(firstThrow + secondThrow + thirdThrow, frame.Total);
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Does_Not_Throw_Exception_On_Two_Strikes()
{
ExtendedAssert.DoesNotThrow(() => new TenthFrame(10, 10, 9));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_First_Throw_Greater_Than_10()
{
ExtendedAssert.Throws<Frame.OverflowException>(() => new TenthFrame(12, 0, 0));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_Throw_Less_Than_Zero()
{
ExtendedAssert.Throws<Frame.UnderflowException>(() => new TenthFrame(2, -1, 12));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_For_5_10_5()
{
ExtendedAssert.Throws<TenthFrame.IllegalFrameException>(() => new TenthFrame(5, 10, 5));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_For_10_5_10()
{
ExtendedAssert.Throws<TenthFrame.IllegalFrameException>(() => new TenthFrame(10, 5, 10));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_3_4_5()
{
ExtendedAssert.Throws<TenthFrame.IllegalFrameException>(() => new TenthFrame(3, 4, 5));
}
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void Throws_Exception_On_7_5_2()
{
ExtendedAssert.Throws<TenthFrame.IllegalFrameException>(() => new TenthFrame(4, 7, 1));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment