示例#1
0
        public void TestWinnerOutcome()
        {
            Dogs.StartingPosition1   = 0;
            Dogs.dogracetrackLength1 = 50;
            int dogRacerAmount = 45;
            int DogsNumber     = 2;
            int expectedWin    = 90;
            int expectedLose   = 0;

            Dogss[0] = new Dogs()
            {
                DogsPictureBox = null
            };
            Dogss[1] = new Dogs()
            {
                DogsPictureBox = null
            };
            Bob      = pFactory.getDogRacer("Bob", null, null);
            Bob.Cash = dogRacerAmount;
            Bob.PlaceBet((int)dogRacerAmount, DogsNumber);

            bool nowin = true;
            int  win   = -1;

            while (nowin)
            {
                for (int i = 0; i < Dogss.Length; i++)
                {
                    if (Dogs.Run(Dogss[i]))
                    {
                        win = i + 1;
                        Bob.Collect(win);
                        nowin = false;
                    }
                }
            }
            if (Bob.bet.dogNum == win)
            {
                Assert.AreEqual(expectedWin, Bob.Cash, "Account doesn't credited ");
            }
            if (Bob.bet.dogNum != win)
            {
                Assert.AreEqual(expectedLose, Bob.Cash, "Account doesn't debited ");
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            int finishPOsition = 50;

            var a = new DogRacer(0);

            //var racers = new List<Animal>();
            var racers = new List <IRacer>();

            racers.Add(a);
            racers.Add(new CatRacer(1));
            racers.Add(new Car(2));

            while (!racers.Any(r => r.Position >= finishPOsition))
            {
                Console.SetCursorPosition(0, 0);

                foreach (var racer in racers)
                {
                    racer.Move();

                    var lineNumber = racer.LineNumber;

                    Draw(racer.Position, lineNumber, racer);

                    if (racer.Position >= finishPOsition)
                    {
                        Console.WriteLine(racer.WinWords());

                        break;
                    }
                }



                Thread.Sleep(300);
            }
            Console.ReadLine();
        }