Example #1
0
        public void Clone()
        {
            var types = Enum.GetValues(typeof(CardType))
                        .Cast <CardType>()
                        .ToList();
            var colors = Enum.GetValues(typeof(CardColor))
                         .Cast <CardColor>()
                         .ToList();
            var cards = new List <Card>();

            colors.ForEach(c => types.ForEach(t => cards.Add(new Card(t, c))));
            var fullSet = new CardSet <Card>(cards.ToArray());

            fullSet.Randomize();
            var clone = (CardSet <Card>)fullSet.Clone();

            Assert.AreNotSame(fullSet, clone);
            Assert.AreEqual(0, fullSet.Except(clone, this).Count());
            for (int i = 0; i < types.Count * colors.Count; i++)
            {
                Assert.AreNotSame(fullSet[i], clone[i]);
                Assert.AreEqual(fullSet[i].Color, clone[i].Color);
                Assert.AreEqual(fullSet[i].Type, clone[i].Type);
            }
        }