Example #1
0
        public void EmptyListIfCycle()
        {
            var cards = new List <TripCard>
            {
                new TripCard("1", "2"),
                new TripCard("2", "3"),
                new TripCard("3", "4"),
                new TripCard("4", "1")
            };

            var fact = CardHelper.GetSortedCards(cards);

            Assert.IsEmpty(fact);
        }
Example #2
0
        public void ShuffleTest()
        {
            var cards = new List <TripCard>();

            for (var i = 0; i < 101; i++)
            {
                cards.Add(new TripCard(i.ToString(), (i + 1).ToString()));
            }

            var rnd           = new Random();
            var cardsShuffled = cards.OrderBy(item => rnd.Next());
            var fact          = CardHelper.GetSortedCards(cardsShuffled);

            CollectionAssert.AreEqual(fact, cards);
        }
Example #3
0
        public void ResultContainsOnlyLinkedCards()
        {
            var cards = new List <TripCard>
            {
                new TripCard("1", "2"),
                new TripCard("2", "3"),
                new TripCard("5", "6"),
                new TripCard("3", "4")
            };

            var fact      = CardHelper.GetSortedCards(cards);
            var expected3 = new List <TripCard>
            {
                new TripCard("1", "2"),
                new TripCard("2", "3"),
                new TripCard("3", "4")
            };

            CollectionAssert.AreEqual(fact, expected3);
        }
Example #4
0
        public void ResultWithoutDuplicates()
        {
            var cards = new List <TripCard>
            {
                new TripCard("1", "2"),
                new TripCard("0", "1"),
                new TripCard("1", "2"),
                new TripCard("0", "1"),
                new TripCard("1", "2")
            };

            var fact     = CardHelper.GetSortedCards(cards);
            var expected = new List <TripCard>
            {
                new TripCard("0", "1"),
                new TripCard("1", "2")
            };

            CollectionAssert.AreEqual(fact, expected);
        }
Example #5
0
 public void EmptyListIfArgumentIsNull()
 {
     Assert.That(() => CardHelper.GetSortedCards(null),
                 Throws.Exception.TypeOf <ArgumentNullException>());
 }
Example #6
0
 public void NullsInList()
 {
     Assert.IsEmpty(CardHelper.GetSortedCards(new List <TripCard> {
         null
     }));
 }