コード例 #1
0
 public GameController(ISlotMachine game, ITransactionService transactionService, UserManager <User> userManager, IUserBalanceService userBalanceService)
 {
     this.game = game;
     this.transactionService = transactionService;
     this.userManager        = userManager;
     this.userBalanceService = userBalanceService;
 }
コード例 #2
0
 public void CheckWin_NotEnoughCoinsInMachine_ThrowException()
 {
     //Arrange
     _machine = new SlotMachine(99);
     //Act //Assert
     Assert.Throws <ArgumentException>(() => _machine.Play(1));
 }
コード例 #3
0
        public CreditCalculator(ISlotMachine slotMachine, int spinCost, int winMultiplier)
        {
            if (slotMachine == null) throw new ArgumentNullException("slotMachine");

            if (spinCost < 1) throw new ArgumentException("spinCost cannot be less than 1");
            if (winMultiplier < 1) throw new ArgumentException("winMultiplier cannot be less than 1");

            SlotMachine = slotMachine;
            SpinCost = spinCost;
            WinMultiplier = winMultiplier;
        }
コード例 #4
0
        public bool NewGame(decimal deposit)
        {
            if (deposit <= 0)
            {
                return(false);
            }

            m_Player = new Player
            {
                Balance = deposit
            };

            m_SlotMachine = new SlotMachine(m_Player, new SymbolGenerator(), new CoefficientCalculator());

            return(true);
        }
コード例 #5
0
        public void Play_Bet1GrapeMiddleRowWon_UserGetReward()
        {
            //Arrange
            _machine        = new SlotMachine(40);
            string[,] slots = new string[3, 3]
            {
                { "🍒", "🍏", "💰" },
                { "🍇", "🍇", "🍇" },
                { "⚜️", "🍒", "🔔" }
            };
            _machine.Slots = slots;
            //Act
            uint reward = _machine.Play(9);

            //Assert
            Assert.Equal(12, (int)reward);
        }
コード例 #6
0
        public void Play_Bet10Coins1000Jackpot_UserGet800Jackpot()
        {
            //Arrange
            string[,] slots = new string[3, 3]
            {
                { "🍒", "🍏", "💰" },
                { "💰", "💰", "💰" },
                { "⚜️", "🍒", "🔔" }
            };
            var slotsRandomizer = new Mock <ISlotsRandomizer>();

            slotsRandomizer.Setup(i => i.Prepare()).Returns(slots);
            _machine = new SlotMachine(1000, slotsRandomizer.Object);
            //Act
            uint reward = _machine.Play(10);

            //Assert
            Assert.Equal(650, (int)reward);
        }
コード例 #7
0
        public void Play_Bet1NotWon_UserGet0Reward()
        {
            //Arrange
            string[,] slots = new string[3, 3]
            {
                { "🍒", "🍏", "💰" },
                { "🍏", "🍇", "🍇" },
                { "⚜️", "🍒", "🔔" }
            };
            var slotsRandomizer = new Mock <ISlotsRandomizer>();

            slotsRandomizer.Setup(i => i.Prepare()).Returns(slots);
            _machine = new SlotMachine(SlotMachineConstants.MINIMUM_COINS, slotsRandomizer.Object);
            //Act
            uint reward = _machine.Play(9);

            //Assert
            Assert.Equal(0, (int)reward);

            slots = new string[3, 3]
            {
                { "🍒", "🍏", "💰" },
                { "🍇", "🍏", "🍇" },
                { "⚜️", "🍒", "🔔" }
            };
            slotsRandomizer.Setup(i => i.Prepare()).Returns(slots);
            //Act
            reward = _machine.Play(9);
            //Assert
            Assert.Equal(0, (int)reward);
            slots = new string[3, 3]
            {
                { "🍒", "🍏", "💰" },
                { "🍇", "🍇", "🍏" },
                { "⚜️", "🍒", "🔔" }
            };
            slotsRandomizer.Setup(i => i.Prepare()).Returns(slots);
            //Act
            reward = _machine.Play(9);
            //Assert
            Assert.Equal(0, (int)reward);
        }
コード例 #8
0
        public void Setup()
        {
            _apple     = new Apple(_symbolSettingsOptions.Value.Apple);
            _pineapple = new Pineapple(_symbolSettingsOptions.Value.Pineapple);
            _banana    = new Banana(_symbolSettingsOptions.Value.Banana);
            _wildCard  = new Wildcard(_symbolSettingsOptions.Value.WildCard);

            _randomSymbolGenerator = Substitute.For <IRandomSymbolGenerator>();
            var slotMachineOptions = Substitute.For <IOptions <SlotMachineSettings> >();

            slotMachineOptions.Value.Returns(new SlotMachineSettings()
            {
                ReelSymbolsCount = 4,
                ReelsCount       = 3,
            });

            var symbolsProvider = Substitute.For <ISymbolsProvider>();

            _slotMachine = new SlotMachine(_randomSymbolGenerator,
                                           slotMachineOptions,
                                           symbolsProvider);
        }
コード例 #9
0
 public PlayerTurn(IReader reader, IWriter writer, ISlotMachine slotMachine)
 {
     _writer      = writer;
     _reader      = reader;
     _slotMachine = slotMachine;
 }
コード例 #10
0
 public WinChecker(ISlotMachine slotMachine)
 {
     _slotMachine = slotMachine;
 }
コード例 #11
0
 public Controller(ISlotMachine slotMachine)
 {
     m_SlotMachine = slotMachine;
 }
コード例 #12
0
 public ConsoleSlotMachine(ISlotMachine slotMachine)
 {
     _slotMachine = slotMachine;
 }
コード例 #13
0
 public SlotMachineUnitTests()
 {
     _slotmachine    = new BusinessLayer.SlotMachine();
     _homecontroller = new HomeController(_slotmachine);
 }
コード例 #14
0
 public SlotGame(IPlayer player, IUserHandler userHandler, ISlotMachine slotMachine)
 {
     this.currentPlayer = player;
     this.userHandler   = userHandler;
     this.slotMachine   = slotMachine;
 }
コード例 #15
0
 public HomeController(ISlotMachine slotmachine)
 {
     _slotmachine = slotmachine;
 }