public void AfterPlayCardWithDrawTwo_CurrentPlayer_ShouldBeCorrectOne() { Player roger = new Player() { Name = "Roger" }; Player livy = new Player() { Name = "Livy" }; Player lucy = new Player() { Name = "Lucy" }; TestRuleProvider ruleProvider = new TestRuleProvider(); ruleProvider.NumberOfCardsToAddResult = 2; Game target = new Game(new Deck(), ruleProvider); target.Players.Add(roger); target.Players.Add(livy); target.Players.Add(lucy); target.Deal(); Card card = roger.Hand.Cards[0]; roger.Hand.Cards.RemoveAt(0); target.PlayCard(card); Assert.AreEqual("Lucy", target.CurrentPlayer.Name); return; }
public void AfterPlayCardCounterClockwise_CurrentPlayer_ShouldBeNextOne() { Player roger = new Player() { Name = "Roger" }; Player livy = new Player() { Name = "Livy" }; Player lucy = new Player() { Name = "Lucy" }; TestRuleProvider ruleProvider = new TestRuleProvider(); ruleProvider.ChangedDirectionResult = true; Game target = new Game(new Deck(), ruleProvider); target.Players.Add(roger); target.Players.Add(livy); target.Players.Add(lucy); target.Deal(); Card card = roger.Hand.Cards[0]; roger.Hand.Cards.RemoveAt(0); target.PlayCard(card); Assert.AreEqual("Lucy", target.CurrentPlayer.Name); return; }
public void UsesCatchAllForNullRegex() { var sut = new TestRuleProvider(LoadConfiguration("Rules/TestRules/defaults.json")); var rules = sut.Load(); Assert.Equal(".*", rules.DefaultRule.Project.ToString()); Assert.Equal(".*", rules.DefaultRule.Repo.ToString()); Assert.Equal(".*", rules.DefaultRule.Tag.ToString()); }
public void ParsesIgnoreList() { var sut = new TestRuleProvider(LoadConfiguration("Rules/TestRules/valid.json")); var rules = sut.Load(); Assert.Single(rules.Rules); var r = rules.Rules[0]; Assert.Single(r.Ignore); Assert.Equal("develop", r.Ignore[0]); }
public void PlayCard_WhenCardCannotBePlayed_ShouldThrow() { TestRuleProvider ruleProvider = new TestRuleProvider(); ruleProvider.CanPlayResult = false; Game target = new Game(new Deck(), ruleProvider); target.Players.Add(new Player()); target.Players.Add(new Player()); target.Deal(); target.PlayCard(new Card(Color.Red, Value.Five)); return; }
public void ParsesDefaultRule() { var sut = new TestRuleProvider(LoadConfiguration("Rules/TestRules/valid.json")); var rules = sut.Load(); Assert.Equal("^foo$", rules.DefaultRule.Project.ToString()); Assert.Equal("^bar$", rules.DefaultRule.Repo.ToString()); Assert.Equal("^baz$", rules.DefaultRule.Tag.ToString()); Assert.Equal(3, rules.DefaultRule.Ignore.Length); Assert.Contains("a", rules.DefaultRule.Ignore); Assert.Contains("b", rules.DefaultRule.Ignore); Assert.Contains("c", rules.DefaultRule.Ignore); Assert.Equal(123, rules.DefaultRule.Keep); }
public void ChooseCardToPlay_WhenCanPlay_ShouldReturnCard() { const int DeckSize = 10; Deck deck = new Deck(new TestDeckProvider(DeckSize)); IRuleProvider ruleProvider = new TestRuleProvider() { CanPlayResult = true }; Game game = new Game(deck, ruleProvider); Player target = new Player(); game.Players.Add(target); game.Deal(); Card card = target.ChooseCardToPlay(game); Assert.IsNotNull(card); return; }
public void ParsesGlobalIgnoreList() { var sut = new TestRuleProvider(LoadConfiguration("Rules/TestRules/valid.json")); var rules = sut.Load(); Assert.Equal(3, rules.IgnoreGlobally.Projects.Length); Assert.Contains("p1", rules.IgnoreGlobally.Projects); Assert.Contains("p2", rules.IgnoreGlobally.Projects); Assert.Contains("p3", rules.IgnoreGlobally.Projects); Assert.Equal(3, rules.IgnoreGlobally.Repos.Length); Assert.Contains("r1", rules.IgnoreGlobally.Repos); Assert.Contains("r2", rules.IgnoreGlobally.Repos); Assert.Contains("r3", rules.IgnoreGlobally.Repos); Assert.Equal(3, rules.IgnoreGlobally.Tags.Length); Assert.Contains("gt1", rules.IgnoreGlobally.Tags); Assert.Contains("gt2", rules.IgnoreGlobally.Tags); Assert.Contains("gt3", rules.IgnoreGlobally.Tags); }
public void AfterPlayCardTwiceCounterClockwise_CurrentPlayer_ShouldBeOriginal() { Player roger = new Player() { Name = "Roger" }; Player livy = new Player() { Name = "Livy" }; Player lucy = new Player() { Name = "Lucy" }; TestRuleProvider ruleProvider = new TestRuleProvider(); ruleProvider.ChangedDirectionResult = true; Game target = new Game(new Deck(), ruleProvider); target.Players.Add(roger); target.Players.Add(livy); target.Players.Add(lucy); target.Deal(); Card card1 = roger.Hand.Cards[0]; roger.Hand.Cards.RemoveAt(0); target.PlayCard(card1); Card card2 = lucy.Hand.Cards[0]; // "Lucy" should be the next player in this reversed case. lucy.Hand.Cards.RemoveAt(0); target.PlayCard(card2); Assert.AreEqual("Roger", target.CurrentPlayer.Name); return; }
public void AfterPlayCardWithDrawTwo_Player_ShouldHaveMoreCards() { Player roger = new Player() { Name = "Roger" }; Player livy = new Player() { Name = "Livy" }; Player lucy = new Player() { Name = "Lucy" }; TestRuleProvider ruleProvider = new TestRuleProvider(); ruleProvider.NumberOfCardsToAddResult = 2; Game target = new Game(new Deck(), ruleProvider); target.Players.Add(roger); target.Players.Add(livy); target.Players.Add(lucy); target.Deal(); int originalHand = livy.Hand.Cards.Count; Card card = roger.Hand.Cards[0]; roger.Hand.Cards.RemoveAt(0); target.PlayCard(card); int newHand = originalHand + 2; // Increment originalHand by NumberOfCardsToAddResult. Assert.AreEqual(newHand, livy.Hand.Cards.Count); return; }
public void ThrowsForNegativeToKeep() { var sut = new TestRuleProvider(LoadConfiguration("Rules/TestRules/negativeToKeep.json")); Assert.Throws <ArgumentException>(() => sut.Load()); }