Ejemplo n.º 1
0
        public async Task Bet_Placed_With_Brand_Timezone(string timezoneId)
        {
            // Arrange
            var brandId = Guid.NewGuid();

            _repository.Brands.Add(new Core.Game.Interface.Data.Brand
            {
                Id         = brandId,
                TimezoneId = timezoneId
            });

            var playerId = Guid.NewGuid();

            _repository.Players.Add(new Core.Game.Interface.Data.Player()
            {
                Id      = playerId,
                BrandId = brandId
            });

            var placeBetAction = GenerateRandomGameAction();

            // Act
            await _commands.PlaceBetAsync(placeBetAction, _GameActionContext, playerId);

            var winBetAction = GenerateRandomGameAction(Guid.NewGuid().ToString());

            winBetAction.TransactionReferenceId = placeBetAction.ExternalTransactionId;
            winBetAction.RoundId = placeBetAction.RoundId;
            winBetAction.Amount  = 25;

            await _commands.WinBetAsync(winBetAction, _GameActionContext);

            // Assert
            var actualRound = _repository.GetRound(x => x.ExternalRoundId == placeBetAction.RoundId);

            var timeComparePattern = "yyyy-MM-dd HH:mm";

            actualRound.Should().NotBeNull();
            actualRound.Data.CreatedOn.ToString(timeComparePattern).Should()
            .Be(DateTimeOffset.UtcNow.ToBrandOffset(timezoneId).ToString(timeComparePattern));
            actualRound.Data.ClosedOn.Value.ToString(timeComparePattern).Should()
            .Be(DateTimeOffset.UtcNow.ToBrandOffset(timezoneId).ToString(timeComparePattern));

            var actualGameAction = actualRound.Data.GameActions[0];

            actualGameAction.GameActionType.Should().Be(GameActionType.Placed);
            actualGameAction.Timestamp.ToString(timeComparePattern).Should()
            .Be(DateTimeOffset.UtcNow.ToBrandOffset(timezoneId).ToString(timeComparePattern));
        }
Ejemplo n.º 2
0
 public async Task WinBet(string roundId, decimal amountWon, string placeBetTxId, string gameProviderCode)
 {
     await _gameCommands.WinBetAsync(
         GameActionData.NewGameActionData(roundId,
                                          amountWon,
                                          "CAD",
                                          transactionReferenceId: placeBetTxId),
         new GameActionContext
     {
         GameProviderCode = gameProviderCode
     });
 }
 async Task <WinBetResponse> ICommonGameActionsProvider.WinBetAsync(WinBet request)
 {
     return(await DoBetCommandTransactions <WinBet, WinBetResponse>(request,
                                                                    async (playerId, transaction) =>
                                                                    await SettleBet(transaction,
                                                                                    (data, context) => _gameCommands.WinBetAsync(data, context))));
 }
Ejemplo n.º 4
0
        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();
                    }
                }
            };
        }