Example #1
0
        public void ShouldSpin(string test, int[] row1RandomNumbers, int[] row2RandomNumbers, int expectedCoefficients)
        {
            // arrange
            _recordedNumbers.AddMany(row1RandomNumbers);
            _recordedNumbers.AddMany(row2RandomNumbers);

            // act
            int coefficient = _spin.Execute().Coefficient;

            // assert
            coefficient.Should().Be(expectedCoefficients);
        }
Example #2
0
        public void ShouldStakeOnceWithdrawAndExit()
        {
            // arrange
            _recordedInteraction
            .AddCharResult(Choice.Deposit)
            .AddDecimalResult(100)
            .AddCharResult(Choice.Stake)
            .AddDecimalResult(20)
            .AddCharResult(Choice.Withdraw)
            .AddCharResult(Choice.Exit);

            // spinning uses 2 rows
            _recordedNumbers.AddMany(new[] { Spin.Apple, Spin.Apple, Spin.Apple });         // 1.2
            _recordedNumbers.AddMany(new[] { Spin.Wildcard, Spin.Pineapple, Spin.Banana }); // 0.0

            // balance after stake of 20 should be 80
            Amount stake             = Amount.Create(20);
            Amount balanceAfterStake = Amount.Create(80);
            // 100 - 20 + 24 = 104
            Amount expectedWithdrawn = Amount.Create(104);

            // act
            _gameEngine.Start();

            // assert
            _gameEngine.Should().HaveExactSteps(new[]
            {
                StateId.DepositOrExit, StateId.Deposit, StateId.StakeOrWithdraw, StateId.Stake, StateId.Spin,
                StateId.StakeOrWithdraw, StateId.Withdraw, StateId.DepositOrExit, StateId.Exit
            });

            using var _ = new AssertionScope();

            AppFlowStep stakeStep = _gameEngine.FindFirstStep(StateId.Stake);

            stakeStep.Should().HaveBalanceAndStake(balanceAfterStake, stake);

            AppFlowStep afterStakeStep = _gameEngine.FindStep(StateId.StakeOrWithdraw, index: 1);

            afterStakeStep.Should().HaveBalanceAndStake(expectedWithdrawn, Amount.Zero);

            AppFlowStep withdrawStep = _gameEngine.FindFirstStep(StateId.Withdraw);

            withdrawStep.Should().HaveZeroBalanceAndZeroStake();

            AppFlowStep lastStep = _gameEngine.Steps.Last();

            lastStep.Should().HaveZeroBalanceAndZeroStake();
        }