Exemple #1
0
        public void PushTest()
        {
            var chipValues = (Chip[])Enum.GetValues(typeof(Chip));
            var chip = chipValues[randGen.Next(0, chipValues.Length)];
            var s = new ChipStack();
            s.Push(chip);
            Assert.AreEqual(1,s.Count);
            Assert.AreEqual(chip,s.Peek());
            Assert.AreEqual(chip,s.Pop());
            Assert.AreEqual(0,s.Count);

            var myChips = new Chip[] { Chip.Purple, Chip.Red, Chip.Green };
            s = new ChipStack();
            foreach (var thisChip in myChips)
            {
                s.Push(thisChip);
            }
            Assert.AreEqual(Chip.Red, s.Pop());
            Assert.AreEqual(Chip.Green, s.Pop());
            Assert.AreEqual(Chip.Purple, s.Pop());

            myChips = new Chip[] { Chip.Purple, Chip.Purple, Chip.Green };
            s = new ChipStack();
            foreach (var thisChip in myChips)
            {
                s.Push(thisChip);
            }
            Assert.AreEqual(Chip.Green, s.Pop());
            Assert.AreEqual(Chip.Purple, s.Pop());
            Assert.AreEqual(Chip.Purple, s.Pop());

            myChips = new Chip[] { Chip.Green, Chip.Green, Chip.Green };
            s = new ChipStack();
            foreach (var thisChip in myChips)
            {
                s.Push(thisChip);
            }
            Assert.AreEqual(Chip.Green, s.Pop());
            Assert.AreEqual(Chip.Green, s.Pop());
            Assert.AreEqual(Chip.Green, s.Pop());

            myChips = new Chip[] { Chip.Black, Chip.Red};
            s = new ChipStack();
            foreach (var thisChip in myChips)
            {
                s.Push(thisChip);
            }
            Assert.AreEqual(Chip.Red, s.Pop());
            Assert.AreEqual(Chip.Black, s.Pop());

            myChips = new Chip[] { Chip.Green, Chip.Red, Chip.Purple };
            s = new ChipStack();
            foreach (var thisChip in myChips)
            {
                s.Push(thisChip);
            }
            Assert.AreEqual(Chip.Red, s.Pop());
            Assert.AreEqual(Chip.Green, s.Pop());
            Assert.AreEqual(Chip.Purple, s.Pop());

            s = new ChipStack();
            for (int i = 0; i < 3; i++)
            {
                chip = chipValues[randGen.Next(0, chipValues.Length)];
                s.Push(chip);
                Console.WriteLine("Inserted: {0}", chip);
            }

            Chip prev = s.Pop();
            while(s.Count>0)
            {
                var current = s.Pop();
                Console.WriteLine("Prev: {0}", prev);
                Console.WriteLine("Current: {0}", current);
                Assert.IsTrue(prev == current || prev < current);
                prev = current;
            }
        }
Exemple #2
0
        public void RemoveAmountTest()
        {
            var s = new ChipStack();
            s.Push(Chip.Purple);

            var s2 = s.RemoveAmount(500);
            Assert.AreEqual(0, s.Count);
            Assert.AreEqual(1, s2.Count);
            Assert.AreEqual(Chip.Purple, s2.Pop());

            bool exThrown = false;
            try
            {
                s2 = s.RemoveAmount(506);
            }
            catch (Exception)
            {
                exThrown = true;
            }
            Assert.IsTrue(exThrown);

            s.Push(Chip.Purple);
            var unchanged = s.Count;
            s2 = s.RemoveAmount(506);
            Assert.AreEqual(0, s2.Count);
            Assert.AreEqual(unchanged, s.Count);

            //s.Push(Chip.Purple);
            for (int i = 0; i < 6; i++)
            {
                s.Push(Chip.White);
            }

            s2 = s.RemoveAmount(506);
            Assert.AreEqual(0, s.Count);
            Assert.AreEqual(7, s2.Count);
            for (int i = 0; i < 6; i++)
            {
                Assert.AreEqual(Chip.White, s2.Pop());
            }
            Assert.AreEqual(Chip.Purple, s2.Pop());
            Assert.AreEqual(0, s.Count);

            s.Push(Chip.Purple);
            s.Push(Chip.Red);
            s.Push(Chip.Green);
            s2 = s.RemoveAmount(506);
            Assert.AreEqual(3, s2.Count);
            Assert.AreEqual(Chip.White, s2.Pop());
            Assert.AreEqual(Chip.Red, s2.Pop());
            Assert.AreEqual(Chip.Purple, s2.Pop());
            Assert.AreEqual(8, s.Count);

            for (var i = 0; i < 4; i++)
            {
                Assert.AreEqual(Chip.White, s.Pop());
            }

            for (var i = 0; i < 4; i++)
            {
                Assert.AreEqual(Chip.Red, s.Pop());
            }
            /*
            Test Name:	MakeBetsTest
            Test Outcome:	Failed
            Result Message:	Assert.AreEqual failed. Expected:<5>. Actual:<4>.
            Result StandardOutput:
            Table minimum bet: 5
            Player cash: 204
            Number of players: 2
            Calculated leftover cash: 199
            Player 0 bet ammount: 4
            */

            var cashStack = Cashier.Exchange(204);
            var removeStack = cashStack.RemoveAmount(5);
            var leftOverCash = 199;
            Assert.AreEqual(leftOverCash, cashStack.GetTotal());

            /*
            Test Name:	MakeBetsTest
            Test Outcome:	Failed
            Result Message:	Assert.AreEqual failed. Expected:<5>. Actual:<0>.
            Result StandardOutput:
            Table minimum bet: 5
            Player cash: 175
            Number of players: 9
            Calculated leftover cash: 170
            Player 0 bet ammount: 0
            */
            cashStack = Cashier.Exchange(175);
            removeStack = cashStack.RemoveAmount(5);
            leftOverCash = 170;
            Assert.AreEqual(leftOverCash, cashStack.GetTotal());
        }
Exemple #3
0
        public void PopTest()
        {
            var s = new ChipStack();
            s.Push(Chip.Green);
            s.Push(Chip.White);
            s.Push(Chip.Red);

            Assert.AreEqual(Chip.White, s.Pop());
            Assert.AreEqual(Chip.Red, s.Pop());
            Assert.AreEqual(Chip.Green, s.Pop());
        }