public async Task Can_Lose_Bet() { // Arrange var placeBetAction = GenerateRandomGameAction(); var playerId = _playerId; await _commands.PlaceBetAsync(placeBetAction, _GameActionContext, playerId); // place initial bet var loseBetAction = GenerateRandomGameAction(Guid.NewGuid().ToString()); loseBetAction.TransactionReferenceId = placeBetAction.ExternalTransactionId; loseBetAction.RoundId = placeBetAction.RoundId; loseBetAction.Amount = 0; loseBetAction.WalletTransactionId = Guid.Empty; _gameWalletsOperationsMock.Setup( t => t.LoseBetAsync(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <string>())) .Returns(Task.FromResult(Guid.NewGuid())); // Act await _commands.LoseBetAsync(loseBetAction, _GameActionContext); // Assert var actualRound = _repository.GetRound(x => x.ExternalRoundId == placeBetAction.RoundId); actualRound.WonAmount.Should().Be(0); actualRound.AdjustedAmount.Should().Be(0); actualRound.Amount.Should().Be(placeBetAction.Amount); actualRound.Data.GameActions.Count.Should().Be(2); var actualLoseBetGameAction = actualRound.Data.GameActions[1]; actualLoseBetGameAction.GameActionType.Should().Be(GameActionType.Lost); actualLoseBetGameAction.WalletTransactionId.Should().BeEmpty(); actualLoseBetGameAction.ExternalTransactionId.Should().Be(loseBetAction.ExternalTransactionId); actualLoseBetGameAction.ExternalBatchId.Should().BeNull(); actualLoseBetGameAction.Description.Should().Be(loseBetAction.Description); actualLoseBetGameAction.Amount.Should().Be(loseBetAction.Amount); actualLoseBetGameAction.Round.Id.Should().Be(actualRound.Data.Id); _eventBusMock.Verify(x => x.Publish(It.IsAny <BetLost>())); }
public async Task LoseBet(string roundId, string placeBetTxId, string gameProviderCode) { await _gameCommands.LoseBetAsync( GameActionData.NewGameActionData(roundId, 0, "CAD", transactionReferenceId: placeBetTxId), new GameActionContext { GameProviderCode = gameProviderCode }); }
async Task <LoseBetResponse> ICommonGameActionsProvider.LoseBetAsync(LoseBet request) { return(await DoBetCommandTransactions <LoseBet, LoseBetResponse>(request, async (playerId, transaction) => await SettleBet(transaction, (data, context) => _gameCommands.LoseBetAsync(data, context)))); }
public UgsGameCommandsAdapter(IGameCommands gameCommands) { _gameCommands = gameCommands; _gameEventsMap = new Dictionary <BusEventType, Action <UgsGameEvent> > { { BusEventType.BetPlaced, @event => { @event.amount = (@event.amount < 0) ? [email protected] : @event.amount; _gameCommands.PlaceBetAsync(GetGameActionData(@event), GetGameActionContext(@event), Guid.Parse(@event.userid)).GetAwaiter().GetResult(); } }, { BusEventType.BetWon, @event => { _gameCommands.WinBetAsync(GetGameActionData(@event), GetGameActionContext(@event)) .GetAwaiter() .GetResult(); } }, { BusEventType.BetLost, @event => { _gameCommands.LoseBetAsync(GetGameActionData(@event), GetGameActionContext(@event)) .GetAwaiter() .GetResult(); } }, { BusEventType.BetFree, @event => { _gameCommands.FreeBetAsync(GetGameActionData(@event), GetGameActionContext(@event), Guid.Parse(@event.userid)).GetAwaiter().GetResult(); } }, { BusEventType.BetTied, @event => { _gameCommands.TieBetAsync(GetGameActionData(@event), GetGameActionContext(@event)) .GetAwaiter() .GetResult(); } }, { BusEventType.BetAdjusted, @event => { _gameCommands.AdjustTransaction(GetGameActionData(@event), GetGameActionContext(@event)); } }, { BusEventType.GameActionCancelled, @event => { _gameCommands.CancelTransactionAsync(GetGameActionData(@event), GetGameActionContext(@event)) .GetAwaiter() .GetResult(); } } }; }