Beispiel #1
0
        public OfferManager(
            ISteamHubConnections steamHubConnections,
            IOfferService offerService,
            RpcSteamListener steamListener,
            ILogServiceFactory logger,
            IGrpcServiceFactory factory,
            IUserService userService,
            IRepoServiceFactory repoServiceFactory
            )
        {
            _rakeItemRepoService = repoServiceFactory.RakeItemRepoService;
            _steamServiceClient  = factory.GetSteamServiceClient(new SteamInventoryCacheManager());
            _steamHubConnections = steamHubConnections;
            _offerService        = offerService;
            _userService         = userService;
            _logger = logger.CreateLogger <OfferManager>();

            steamListener.OnOfferStatusChanged += async(sender, offer) =>
            {
                _logger.Info($"Received statuscode {offer.StatusCode}");

                try
                {
                    await HandleOffer(offer);
                }
                catch (System.Exception e)
                {
                    _logger.Error(offer.SteamId, null, e, new Dictionary <string, object>
                    {
                        { "Offer", offer }
                    });
                }
            };
        }
Beispiel #2
0
 public TestController(
     ISteamHubConnections steamHubConnections,
     IMatchHubConnections matchHubConnections,
     IRepoServiceFactory repoServiceFactory,
     IJackpotMatchManager jackpotMatchManager,
     ICoinFlipManager coinFlipManager,
     IDatabaseConnectionFactory connectionFactory,
     IGrpcServiceFactory grpcService
     )
 {
     _steamHubConnections   = steamHubConnections;
     _repoServiceFactory    = repoServiceFactory;
     _jackpotMatchManager   = jackpotMatchManager;
     _coinFlipManager       = coinFlipManager;
     _discordSercviceClient = grpcService.GetDiscordSercviceClient();
 }
        public OfferManagerTest()
        {
            _fakedSteamHubConnection = A.Fake <ISteamHubConnections>();
            _fakedOfferService       = A.Fake <IOfferService>();
            _fakedGrpcServiceFactory = A.Fake <IGrpcServiceFactory>();
            _fakedUserService        = A.Fake <IUserService>();
            _loggerDummy             = A.Dummy <ILogServiceFactory>();
            _fakedSteamServiceClient = A.Fake <ISteamServiceClientWrapper>();
            _fakedRepoServiceFactory = A.Fake <IRepoServiceFactory>();
            _fakedRakeItemRepo       = A.Fake <IRakeItemRepoService>();

            A.CallTo(() => _fakedRepoServiceFactory.RakeItemRepoService).Returns(_fakedRakeItemRepo);

            _offerMinmalInfo = new OfferStatusRequest
            {
                Bot = new Bot
                {
                    Username = "******",
                    SteamId  = "botSteamId"
                },
                SteamId       = "user Steamid",
                StatusCode    = int.MinValue,
                StatusMessage = "",
                OfferSend     = new OfferStatusOffer
                {
                    SteamOffer = new SteamOffer
                    {
                        ItemsToGive =
                        {
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "1"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "2"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "3"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "4"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "5"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "6"
                            },
                        },
                        ItemsToReceive =
                        {
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "11"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "12"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "13"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "14"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "15"
                            },
                            new Item {
                                AppId = 730, ContextId = "2", AssetId = "16"
                            },
                        },
                    }
                }
            };

            var userFindRes =
                Task.FromResult(new DatabaseModel.User(_offerMinmalInfo.SteamId, null, null, null, DateTime.Today, DateTime.Today, false));

            A.CallTo(() => _fakedUserService.FindAsync(_offerMinmalInfo.SteamId)).Returns(userFindRes);
            A.CallTo(() => _fakedGrpcServiceFactory.GetSteamServiceClient(A <ISteamInventoryCacheManager> ._)).Returns(_fakedSteamServiceClient);

            A.CallTo(() => _fakedSteamServiceClient.GetPlayerInfoAsync(new GetPlayerInfoRequest
            {
                SteamId = _offerMinmalInfo.SteamId
            })).Returns(Task.FromResult(new GetPlayerInfoResponse
            {
                PlayerInfo = new PlayerInfo
                {
                    Avatar      = "",
                    PersonaName = ""
                }
            }));
        }