public void AnErrorIsThrownIfAPlayerHasAVisitWhoIsNotInTheLeg() { var leg = new Leg(501); var player = new Player("Andy"); var visit = new Visit(player, 100); var newScore = leg.Visit(visit); }
public void APlayerCanHaveAVisitAndSeeTheirScoreChange() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var newScore = leg.Visit(visit); Assert.AreEqual(401, newScore); }
public void AnErrorIsThronWhenAPlayerReaches0WithAnImpossibleCheckout() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var checkoutVisit = new Visit(player, 101); leg.Visit(new Visit(player, 100));//401 leg.Visit(new Visit(player, 100));//301 leg.Visit(new Visit(player, 100));//201 leg.Visit(new Visit(player, 39));//162 leg.Visit(new Visit(player, 162)); }
public void APlayersScoreCanReachExacly0() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); var checkoutVisit = new Visit(player, 101); leg.Visit(visit);//401 leg.Visit(visit);//301 leg.Visit(visit);//201 leg.Visit(visit);//101 var score = leg.Visit(checkoutVisit);//1 = bust, therefore 101 Assert.AreEqual(0, leg.Players[0].Score); }
public int Visit(Visit visit) { var player = Players.Where(p => p.Name.Equals(visit.Player.Name)).FirstOrDefault(); if (player == null) throw new Exception("Player is not in the leg."); var newScore = player.Score - visit.Score; if (newScore < 2 && newScore != 0) newScore = player.Score; if (newScore == 0) ValidateCheckout(player.Score); return player.Score = newScore; }
public void APlayersScoreRemainsTheSameWhenTheirOverallScoreGoBelow2() { var leg = new Leg(501); var player = new Player("Andy"); leg.AddPlayer(player); var visit = new Visit(player, 100); leg.Visit(visit);//401 leg.Visit(visit);//301 leg.Visit(visit);//201 leg.Visit(visit);//101 var score = leg.Visit(visit);//1 = bust, therefore 101 Assert.AreEqual(101, leg.Players[0].Score); }
public void AnErrorIsThrownWhenAnInvalidScoreIsAddedToAVisit() { var player = new Player("Andy"); var visit = new Visit(player, 175); }
public void AnErrorIsThrownIfAPlayerHasAScoreLessThan0() { var player = new Player("Andy"); var visit = new Visit(player, -1); }
public void AnErrorIsThrownIfAPlayerHasAScoreHigherThan180() { var player = new Player("Andy"); var visit = new Visit(player, 181); }