public void Can_Free_Bet() { // Arrange var freeBetAction = GenerateRandomGameAction(); var brandId = _brandId; var playerId = _playerId; _gameWalletsOperationsMock.Setup( t => t.FreeBetAsync(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <decimal>(), It.IsAny <string>())) .Returns(Task.FromResult(Guid.NewGuid())); // Act _commands.FreeBetAsync(freeBetAction, _GameActionContext, playerId); // Assert var actualRound = _repository.GetRound(x => x.ExternalRoundId == freeBetAction.RoundId); actualRound.Should().NotBeNull(); actualRound.Data.PlayerId.Should().Be(playerId); actualRound.Data.BrandId.Should().Be(brandId); actualRound.Data.GameId.Should().Be(_gameId); actualRound.Data.Status.Should().Be(RoundStatus.Closed); actualRound.WonAmount.Should().Be(freeBetAction.Amount); actualRound.AdjustedAmount.Should().Be(0); actualRound.Amount.Should().Be(0); actualRound.Data.GameActions.Should().NotBeEmpty(); var actualGameAction = actualRound.Data.GameActions[0]; actualGameAction.GameActionType.Should().Be(GameActionType.Free); actualGameAction.WalletTransactionId.Should().NotBeEmpty(); actualGameAction.ExternalTransactionId.Should().Be(freeBetAction.ExternalTransactionId); actualGameAction.ExternalBatchId.Should().BeNull(); actualGameAction.Description.Should().Be(freeBetAction.Description); actualGameAction.Amount.Should().Be(freeBetAction.Amount); actualGameAction.Round.Id.Should().Be(actualRound.Data.Id); _eventBusMock.Verify(x => x.Publish(It.IsAny <BetPlacedFree>())); }
async Task <FreeBetResponse> ICommonGameActionsProvider.FreeBetAsync(FreeBet request) { return(await DoBetCommandTransactions <FreeBet, FreeBetResponse>(request, async (playerId, transaction) => await SettleBet(transaction, (data, context) => _gameCommands.FreeBetAsync(data, context, playerId)))); }
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(); } } }; }