예제 #1
0
        public void RouletteGame_PayUp_Test()
        {
            // Setting up Substitudes
            var _fakeRoulette = Substitute.For <IRoulette>();
            var _fakeField    = Substitute.For <Field>(10u, Field.Black);
            var _bet          = Substitute.For <FieldBet>("SubBet", 20u, 10u);

            // Setting up Sub returnCalls
            _bet.WonAmount(_fakeField).Returns(50u);
            _fakeRoulette.GetResult().Returns(_fakeField);

            var uut = new RouletteGame.Legacy.RouletteGame(_fakeRoulette);

            uut.OpenBets();

            uut.PlaceBet(_bet);

            uut.CloseBets();

            uut.PayUp();

            _bet.Received(1).WonAmount(_fakeField);

            _fakeRoulette.Received(1).GetResult();
        }
예제 #2
0
        public void RouletteOpenBet()
        {
            var roulette = new FakeRoulette();
            var uut      = new RouletteGame.Legacy.RouletteGame(roulette);

            uut.OpenBets();

            Assert.That(uut.RoundIsOpen, Is.EqualTo(true));
        }
예제 #3
0
        public void TestFakeSpin()
        {
            var RL = new FakeRoulette();

            RouletteGame.Legacy.RouletteGame RG = new RouletteGame.Legacy.RouletteGame(RL);
            RG.OpenBets();
            RG.PlaceBet(new ColorBet("player 1", 100, Field.Black));
            RG.CloseBets();
            RG.SpinRoulette();
            Assert.AreEqual(1, RL.CountGetResult);
        }
예제 #4
0
        public void RouletteGame_Place_Bet_Closed_Bet_Expect_Exception()
        {
            var uut = new RouletteGame.Legacy.RouletteGame(Substitute.For <IRoulette>());

            uut.OpenBets();
            uut.CloseBets();

            Assert.Throws <RouletteGameException>(
                () => uut.PlaceBet(new EvenOddBet("hello", 5, true))
                );
        }
예제 #5
0
        public void RoulettePayUp_TestBetWonAmount()
        {
            var roulette = new Roulette(new Randomizer());
            var uut      = new RouletteGame.Legacy.RouletteGame(roulette);
            var fakeBet  = new FakeBet("FakeBet", 100);

            uut.OpenBets();
            uut.PlaceBet(fakeBet);
            uut.PayUp();

            Assert.That(fakeBet.WonAmountWasCalled, Is.EqualTo(true));
        }
예제 #6
0
        public void CanBlackWin()
        {
            Field field = new Field(1, 1);
            var   game  = new RouletteGame.Legacy.RouletteGame(new FakeRoulette(field));

            game.OpenBets();
            Bet bet = new ColorBet("Fake Player", 100, 1);

            game.PlaceBet(bet);
            game.CloseBets();
            game.SpinRoulette();
            game.PayUp();
            Assert.That(game.FakePayUp(bet).Equals(bet.WonAmount(field)));
        }
예제 #7
0
 public void CanAllFieldWin()
 {
     for (uint i = 0; i < 37; i++)
     {
         Field field = new Field(i, 0);
         var   game  = new RouletteGame.Legacy.RouletteGame(new FakeRoulette(field));
         game.OpenBets();
         Bet bet = new FieldBet("Fake Player", 100, i);
         game.PlaceBet(bet);
         game.CloseBets();
         game.SpinRoulette();
         game.PayUp();
         Assert.That(game.FakePayUp(bet).Equals(bet.WonAmount(field)));
     }
 }
예제 #8
0
        static void Main(string[] args)
        {
            var game = new RouletteGame(new Roulette(new Randomzier(), new FieldFactory()));

            game.OpenBets();
            game.PlaceBet(new ColorBet("Player 1", 100, Field.Black));
            game.PlaceBet(new ColorBet("Player 1", 100, Field.Red));

            game.PlaceBet(new EvenOddBet("Player 2", 100, true));
            game.PlaceBet(new EvenOddBet("Player 2", 100, false));

            for (uint i = 0; i < 36; i++)
            {
                game.PlaceBet(new FieldBet("Player 3", 100, i));
            }

            game.CloseBets();
            game.SpinRoulette();
            game.PayUp();
        }
        private static void Main()
        {
            var game = new RouletteGame(new Roulette());

            game.OpenBets();
            game.PlaceBet(new ColorBet("Player 1", 100, Field.Black));
            game.PlaceBet(new ColorBet("Player 1", 100, Field.Red));


            game.PlaceBet(new EvenOddBet("Player 2", 100, true));
            game.PlaceBet(new EvenOddBet("Player 2", 100, false));

            for (uint i = 0; i < 36; i++)
            {
                game.PlaceBet(new FieldBet("Player 3", 100, i));
            }

            game.CloseBets();
            game.SpinRoulette();
            game.PayUp();
        }