Пример #1
0
        public async Task SendSellRakeOfferWasAcceptedSuccess()
        {
            _offerMinmalInfo.StatusCode = 6;
            _offerMinmalInfo.OfferSend.SteamOffer.Message = "sendSellRakeOffer";

            var offerManager = new OfferManager(
                _fakedSteamHubConnection,
                _fakedOfferService,
                new RpcSteamListener(_loggerDummy),
                _loggerDummy,
                _fakedGrpcServiceFactory,
                _fakedUserService,
                _fakedRepoServiceFactory
                );

            await offerManager.HandleOffer(_offerMinmalInfo);

            A.CallTo(() => _fakedRakeItemRepo.SetAsSold(A <List <string> > .That.Matches(l => l.Count == 6))).MustHaveHappened();
            A.CallTo(() => _fakedSteamHubConnection.SendOfferStatusToUser(A <OfferStatusRequest> ._, A <string> ._)).MustNotHaveHappened();
        }
        public async void SetRakeItemAsSold()
        {
            var item = new DatabaseModel.RakeItem("randAssetId123", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode.Id);
            var item2 = new DatabaseModel.RakeItem("randAssetId124", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);

            Assert.False(item.IsSold);
            Assert.False(item2.IsSold);

            await _rakeItemRepoService.InsertAsync(new List <DatabaseModel.RakeItem>
            {
                item,
                item2
            });

            await _rakeItemRepoService.SetAsSold(new List <string>
            {
                "randAssetId123"
            });

            var item1Res = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "randAssetId123",
                DescriptionId = _setup.ItemDescription2.Id,
            });

            var item2Res = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "randAssetId124",
                DescriptionId = _setup.ItemDescription1.Id,
            });

            Assert.True(item1Res.IsSold);
            Assert.False(item2Res.IsSold);
        }
Пример #3
0
        public async Task HandleOffer(OfferStatusRequest offer)
        {
            try
            {
                if (offer.DataCase == OfferStatusRequest.DataOneofCase.OfferSend && offer.OfferSend.SteamOffer.Message == "sendSellRakeOffer")
                {
                    var itemsSuccessfulySentToBot = offer.OfferSend.SteamOffer.ItemsToGive;
                    var assetIds = itemsSuccessfulySentToBot.Select(item => item.AssetId).ToList();

                    await _rakeItemRepoService.SetAsSold(assetIds);

                    return;
                }
            }
            catch (System.Exception e)
            {
                _logger.Error(offer.SteamId, null, e, new Dictionary <string, object>
                {
                    { "Offer", offer }
                });
                return;
            }

            if (offer.DataCase == OfferStatusRequest.DataOneofCase.Error)
            {
                await _steamHubConnections.SendErrorMessageRelatedToOurApi("Internal error processing offer, please try again later!", offer.SteamId);

                return;
            }

            FixSteamItemsBadNaming(offer);

            switch (offer.StatusCode)
            {
            case 5:
                await HandleDeposit(offer);

                break;

            case 6:
                await HandleWithdrawal(offer);

                break;

            case 14:
            case 16:
            case 19:
            case 20:
                await RemoveCanceledOfferFromOfferTransaction(offer);

                break;
            }

            var request = new OfferStatusRequest
            {
                StatusCode = offer.StatusCode,
                SteamId    = offer.SteamId,
                OfferSend  = offer.OfferSend
            };
            await _steamHubConnections.SendOfferStatusToUser(request, offer.SteamId);
        }