public void TestAddDuplicateCardThrowsAnException() { // ARRANGE IAxiom axiom = new Axiom(); IList <ICard> cards = new List <ICard> { new Card(Colour.Orange, Number.Three, axiom), new Card(Colour.Blue, Number.Seven, axiom), new Card(Colour.Red, Number.One, axiom) }; ICard duplicateCard = new Card(Colour.Orange, Number.Three, axiom); IPalette palette = new Palette(cards); // ACT ArgumentException argumentException = null; try { palette.AddCard(duplicateCard); } catch (ArgumentException ex) { argumentException = ex; } // ASSERT if (argumentException != null) { Console.WriteLine(argumentException.ToString()); } Assert.IsNotNull(argumentException, "Expected exception not thrown"); }
public void TestAddCardAddsTheCardToThePalette() { // ARRANGE IAxiom axiom = new Axiom(); IList <ICard> cards = new List <ICard> { new Card(Colour.Orange, Number.Three, axiom), new Card(Colour.Blue, Number.Seven, axiom), new Card(Colour.Red, Number.One, axiom) }; ICard card = new Card(Colour.Violet, Number.Four, axiom); IPalette palette = new Palette(cards); // ACT palette.AddCard(card); // ASSERT Assert.AreEqual(expected: cards.Count + 1, actual: palette.Cards.Count); bool found = palette.Cards .Where(c => c.Colour == card.Colour) .Any(c => c.Number == card.Number); Assert.IsTrue(found, "Card exists"); }