public void ShouldLoseAllAndExit() { // arrange _recordedInteraction .AddCharResult(Choice.Deposit) .AddDecimalResult(100) .AddCharResult(Choice.Stake) .AddDecimalResult(100) .AddCharResult(Choice.Exit); // spinning uses 2 rows _recordedNumbers.AddMany(new[] { Spin.Banana, Spin.Apple, Spin.Apple }); // 0.0 _recordedNumbers.AddMany(new[] { Spin.Wildcard, Spin.Pineapple, Spin.Banana }); // 0.0 // act _gameEngine.Start(); // assert _gameEngine.Should().HaveExactSteps(new[] { StateId.DepositOrExit, StateId.Deposit, StateId.StakeOrWithdraw, StateId.Stake, StateId.Spin, StateId.StakeOrWithdraw, StateId.DepositOrExit, StateId.Exit }); AppFlowStep spinStep = _gameEngine.FindFirstStep(StateId.Spin); spinStep.Should().HaveZeroBalanceAndZeroStake(); }
protected override void Notify(State currentState) { AppFlowStep step = new AppFlowStep(currentState, _wallet.Balance, _wallet.Stake, _output.Messages); _steps.Add(step); _output.Messages.Clear(); }
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(); }