Exemplo n.º 1
0
        public async Task RemoveCanceledWithdrawalSteamOffer(OfferStatusRequest request)
        {
            var offerTransaction = await _offerRepoService.FindAsync(request.OfferSend.SteamOffer.Id);

            await _itemInOfferTransactionRepoService.Remove(offerTransaction.Id);

            await _offerRepoService.Remove(offerTransaction.Id);
        }
Exemplo n.º 2
0
        public async Task UserWithdrawlOfferWasCanceled()
        {
            _offerMinmalInfo.OfferSend.SteamOffer.ItemsToReceive.Clear();
            _offerMinmalInfo.OfferSend.SteamOffer.Id = "12346";

            A.CallTo(() => _fakedOfferTranascrionRepoService.FindAsync("12346"))
            .Returns(new DatabaseModel.OfferTransaction(0, 0, 0, false, "123456", null, 10));
            await _offerService.RemoveCanceledWithdrawalSteamOffer(_offerMinmalInfo);

            A.CallTo(() => _fakedOfferTranascrionRepoService.Remove(10)).MustHaveHappened();
            A.CallTo(() => _fakedItemInOfferTransactionRepoService.Remove(10)).MustHaveHappened();
            A.CallTo(() => _fakedOfferTranascrionRepoService.FindAsync("12346")).MustHaveHappened();
        }
Exemplo n.º 3
0
        public async void UserWithdrawsSuccessButSteamBotReturnsError()
        {
            var listOfAssetAndDescriptionId = new List <AssetAndDescriptionId>
            {
                new AssetAndDescriptionId {
                    AssetId = "assetId1", DescriptionId = 2
                },
                new AssetAndDescriptionId {
                    AssetId = "assetId2", DescriptionId = 2
                },
                new AssetAndDescriptionId {
                    AssetId = "assetId3", DescriptionId = 2
                },
            };

            _realUsersItems = new List <DatabaseModel.Item>
            {
                new DatabaseModel.Item("assetId1", 2, 5, _realUser.Id, DateTimeOffset.Now),
                new DatabaseModel.Item("assetId2", 2, 5, _realUser.Id, DateTimeOffset.Now),
                new DatabaseModel.Item("assetId3", 2, 5, _realUser.Id, DateTimeOffset.Now),
            };

            A.CallTo(() => _fakedItemDescRepoService.FindAsync(A <List <int> > ._)).Returns(new List <DatabaseModel.ItemDescription>
            {
                new DatabaseModel.ItemDescription("itemDesc5", new decimal(5.55), "730", "2", "imgUlr", true, 2),
                new DatabaseModel.ItemDescription("itemDesc5", new decimal(5.55), "730", "2", "imgUlr", true, 2),
                new DatabaseModel.ItemDescription("itemDesc5", new decimal(5.55), "730", "2", "imgUlr", true, 2),
            });

            A.CallTo(() => _fakedSteamServiceClient.MakeOfferAsync(A <MakeOfferRequest> ._)).Returns(new MakeOfferResponse
            {
                Error = new Error
                {
                    Message = "Error!!"
                }
            });

            A.CallTo(() => _fakedOfferService.PrepareWithdrawlSteamOffer(
                         A <List <Item> > .That.Matches(list => list.Count == 3),
                         A <DatabaseModel.Bot> .That.Matches(bot => bot.SteamId == "botSteamId"),
                         A <DatabaseModel.User> .That.Matches(user => user.SteamId == _realUser.SteamId)
                         )).Returns(new DatabaseModel.OfferTransaction(0, 0, Decimal.One, false, null, null, 10));


            var offers = new Dictionary <DatabaseModel.Bot, List <DatabaseModel.Item> >();

            offers.Add(new DatabaseModel.Bot("botSteamId", "botName", 5), _realUsersItems);

            A.CallTo(() => _fakedBotService.GetBotsWithWithdrawItems(listOfAssetAndDescriptionId)).Returns(offers);

            var respose = await _steamService.MakeWithdrawOfferAsync(_realUser.SteamId, listOfAssetAndDescriptionId);

            Assert.Equal(1, respose.Count);

            A.CallTo(() => _fakedSteamServiceClient.MakeOfferAsync(A <MakeOfferRequest> .That.Matches(
                                                                       offer => offer.SendItems &&
                                                                       offer.Items.Count == 3 &&
                                                                       offer.User.SteamId == _realUser.SteamId &&
                                                                       offer.BotName == "botName"
                                                                       )))
            .MustHaveHappened();

            A.CallTo(() => _fakedOfferTransactionRepoService.Remove(10)).MustHaveHappened();
            A.CallTo(() => _fakedOfferService.PrepareWithdrawlSteamOffer(
                         A <List <Item> > .That.Matches(list => list.Count == 3),
                         A <DatabaseModel.Bot> .That.Matches(bot => bot.SteamId == "botSteamId"),
                         A <DatabaseModel.User> .That.Matches(user => user.SteamId == _realUser.SteamId)
                         )).MustHaveHappened();
        }