Beispiel #1
0
        static void Main(string[] args)
        {
            SimpleSlotMachine slotMachine = BuildMachine();

            Console.WriteLine("Welcome to the Simple Slot Machine");
            string userCommand;

            Console.WriteLine("Please enter deposit");
            decimal deposit = TryParseInputToDecimal(Console.ReadLine());

            slotMachine.EnterDeposit(new Money(deposit));

            do
            {
                Console.WriteLine($"Your balance is {slotMachine.Balance.Amount}");
                Console.WriteLine("Now stake some money");
                decimal stake = TryParseInputToDecimal(Console.ReadLine());
                slotMachine.StakeMoney(new Money(stake));
                Console.WriteLine($"Your balance is {slotMachine.Balance.Amount}");

                slotMachine.Play();


                if (slotMachine.Balance.Amount == 0)
                {
                    Console.WriteLine();
                    Console.WriteLine("Your deposit finished. Goodbye");
                    return;
                }

                Console.WriteLine("Do you want to continue? yes/no");
                userCommand = Console.ReadLine();
            }while (userCommand == continueCommand);
        }
Beispiel #2
0
        public void User_win_money_when_winning_combinantion_appear()
        {
            //Arrange
            decimal deposit = 200;
            decimal stake   = 10;
            var     engine  = new Mock <ISimpleEngine>();

            engine.Setup(x => x.SpinTheReel()).Returns(WinCombinationApples);
            var slotMachine = new SimpleSlotMachine(engine.Object);

            //Act
            slotMachine.EnterDeposit(new Money(deposit));
            slotMachine.StakeMoney(new Money(stake));
            slotMachine.Play();

            //Assert
            slotMachine.Balance.Amount.Should().BeGreaterThan(deposit - stake);
        }
Beispiel #3
0
        public void User_win_less_than_stake_when_won_with_one_wildcard_only()
        {
            //Arrange
            decimal deposit = 200;
            decimal stake   = 10;
            var     engine  = new Mock <ISimpleEngine>();

            engine.Setup(x => x.SpinTheReel()).Returns(WinCombinationWildCards);
            var slotMachine = new SimpleSlotMachine(engine.Object);

            //Act
            slotMachine.EnterDeposit(new Money(deposit));
            slotMachine.StakeMoney(new Money(stake));
            slotMachine.Play();

            //Assert
            slotMachine.Balance.Amount.Should().BeLessThan(deposit).And.BeGreaterThan(deposit - stake);
        }