public void TestStart() { var controller = new BowlingController(); controller.Start(); Assert.True(File.Exists(DbFileController.filePath)); }
public void TestExceptionHandlingRangeFirstRoll() { var controller = new BowlingController(); controller.Start(); // The number of pin should be in the [0,10] range. Assert.Throws <ArgumentOutOfRangeException>(() => controller.Play(12)); }
public void TestExceptionHandlingRangeSecondRoll() { var controller = new BowlingController(); controller.Start(); controller.Play(3); /// The maximum number of pins is 7 for the second roll. Assert.Throws <ArgumentOutOfRangeException>(() => controller.Play(8)); }
public void SpareInLastFrameTest() { BowlingController gameTest = new BowlingController(); string gameValue = "8,2|10|7,3|10|10|10|10|10|10|7,3,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 247; Assert.AreEqual(expectedValue, valueReturned); }
public void FirstAndThirdFrameMissedSpareTest() { BowlingController gameTest = new BowlingController(); string gameValue = "8,2|10|7,3|10|10|10|10|10|10|10,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 270; Assert.AreEqual(expectedValue, valueReturned); }
public void MiddleFrameMissedStrikeTest() { BowlingController gameTest = new BowlingController(); string gameValue = "10|10|10|10|10|0,0|10|10|10|10,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 240; Assert.AreEqual(expectedValue, valueReturned); }
public void GreaterThan10Test() { BowlingController gameTest = new BowlingController(); string gameValue = "0,0|100|10|10|10|10|10|10|8,1|0,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 0; //This test is done in the Console for now, but will return 0. Assert.AreEqual(expectedValue, valueReturned); }
public void RandomTestOnFinalFrame() { BowlingController gameTest = new BowlingController(); string gameValue = "0,0|10|10|10|10|10|10|10|8,1|0,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 226; Assert.AreEqual(expectedValue, valueReturned); }
public void AnotherRandomStrikeTest() { BowlingController gameTest = new BowlingController(); string gameValue = "0,0|10|10|10|10|10|10|10|8,2|0,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 228; Assert.AreEqual(expectedValue, valueReturned); }
public void SeriouslyUnluckyBowlerTest() { BowlingController gameTest = new BowlingController(); string gameValue = "0,0|0,0|0,0|0,0|0,0|0,0|0,0|0,0|0,0|8,2,0"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 10; Assert.AreEqual(expectedValue, valueReturned); }
public void PerfectGameTest() { BowlingController gameTest = new BowlingController(); string gameValue = "10|10|10|10|10|10|10|10|10|10,10,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 300; Assert.AreEqual(expectedValue, valueReturned); }
public void BadBowlerTest() { BowlingController gameTest = new BowlingController(); string gameValue = "0,0|0,0|0,0|0,0|0,0|0,0|0,0|0,0|0,0|0,0,0"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 0; Assert.AreEqual(expectedValue, valueReturned); }
public void RandomsTest() { BowlingController gameTest = new BowlingController(); string gameValue = "8,1|5,3|7,2|10|8,2|2,4|10|8,1|10|7,3,10"; int valueReturned = gameTest.BowlingGame(gameValue); int expectedValue = 132; Assert.AreEqual(expectedValue, valueReturned); }
public void TestExceptionHandlingGameOver() { var controller = new BowlingController(); controller.Start(); for (int i = 0; i < 12; i++) { controller.Play(10); } // The game is over. Assert.Throws <ApplicationException>(() => controller.Play(8)); }
public void TestPlayAndScore() { var controller = new BowlingController(); controller.Start(); int[] game = { 2, 2, 5, 5, 10, 2, 0, 0, 3 }; int[] excpectedResults = { 4, 24, 36, 38, 41, -1, -1, -1, -1, -1 }; foreach (int roll in game) { controller.Play(roll); } var apiResults = controller.Scores(); Assert.True(Enumerable.SequenceEqual(apiResults.Value.Frames, excpectedResults)); Assert.Equal(apiResults.Value.TotalScore, excpectedResults.Max()); }
public void SetUp() { _bowlingController = new BowlingController(); }