public void TestNoFrames() { BowlingFrames bowlingFrames = new BowlingFrames(new List <BowlingFrame>()); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(0, br.CountScore().Score, "Test No Frames"); }
public void StrikeFrameCreation() { var roll1 = new Roll(10); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1 }); Assert.IsType <StrikeFrame>(frame); }
public void OpenFrameCreation() { var roll1 = new Roll(4); var roll2 = new Roll(2); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }); Assert.IsType <OpenFrame>(frame); }
public void LastFrameCreationWith_TwoRolls() { var roll1 = new Roll(1); var roll2 = new Roll(1); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }, 10); Assert.IsType <LastFrame>(frame); }
public void SpareFrameCreation() { var roll1 = new Roll(5); var roll2 = new Roll(5); IBowlingFrame frame = BowlingFrames.From(new Roll[] { roll1, roll2 }); Assert.IsType <SpareFrame>(frame); }
public void TestSpareFrame() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(6, 4)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(10, br.CountScore().Score, "Test Spare Frame"); }
public void TestTwoSparesInARow() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(6, 4)); list.Add(new BowlingFrame(5, 5)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(25, br.CountScore().Score, "Test Two Spares in a row"); }
public void TestSpareFrameWithFollowingFrame() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(6, 4)); list.Add(new BowlingFrame(5, 3)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(23, br.CountScore().Score, "Test Spare Frame with a frame that follows"); }
public void TestTenFrame() { List <BowlingFrame> list = new List <BowlingFrame>() { new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1), new BowlingFrame(1, 1) }; BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(20, br.CountScore().Score, "Test Ten Frames"); }
public void TestZeroFrame() { List <BowlingFrame> list = new List <BowlingFrame>() { new BowlingFrame(0, 0) }; BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(0, br.CountScore().Score, "Test Zero-Frame"); }
public void TestStrikeFrameWithFollowingFrame() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(5, 3)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(26, br.CountScore().Score, "Test Strike Frame with a regular following frame"); }
public void TestThreeStrikesInARow() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(60, br.CountScore().Score, "Test three strikes in a row"); }
public void TestPerfectGame() { List <BowlingFrame> list = new List <BowlingFrame>(); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 0)); list.Add(new BowlingFrame(10, 10)); BowlingFrames bowlingFrames = new BowlingFrames(list); var br = new BowlingRepository(bowlingFrames); Assert.AreEqual(300, br.CountScore().Score, "Test Perfect Game"); }
public BowlingRepository(BowlingFrames bowlingFrames) { framesList = bowlingFrames.Frames; rollList = new List <int>(); foreach (var frame in framesList) { rollList.Add(frame.First); rollList.Add(frame.Second); if (frame.Third != 0) { rollList.Add(frame.Third); } } if (framesList.Count < 10) { for (var i = framesList.Count; i < 10; i++) { rollList.Add(0); rollList.Add(0); framesList.Add(new BowlingFrame(0, 0)); } } }
public IHttpActionResult Post(BowlingFrames frames) { BowlingRepository br = new BowlingRepository(frames); return(Ok(br.CountScore())); }