public async Task UserDepositItemsSuccess() { _offerMinmalInfo.OfferSend.SteamOffer.ItemsToGive.Clear(); var offerTransInsertWithId = new DatabaseModel.OfferTransaction(1, 14, new decimal(196.91), true, "12345", DateTime.Today, 75); var userInsertRes = new DatabaseModel.User("userSteamId", "name", "img", "tradeLink", DateTime.Today, DateTime.Today, false, null, 1); A.CallTo(() => _fakedUserRepoService.FindAsync("userSteamId")).Returns(userInsertRes); var botLookRes = Task.FromResult(new DatabaseModel.Bot("botSteamId", "botName", 14)); A.CallTo(() => _fakedBotRepoService.FindAsync("botSteamId")).Returns(botLookRes); A.CallTo(() => _fakedOfferTranascrionRepoService.InsertAsync(A <DatabaseModel.OfferTransaction> .That.Matches(o => o.IsDeposit && o.Accepted > DateTime.Today && o.BotId == 14 && o.UserId == 1 && o.Id == 0 && o.TotalValue == new decimal(196.91) ), A <ITransactionWrapper> ._)).Returns(offerTransInsertWithId); await _offerService.DepositSteamOfferAsync(_offerMinmalInfo); A.CallTo(() => _fakedOfferTranascrionRepoService.InsertAsync(A <DatabaseModel.OfferTransaction> .That.Matches(o => o.IsDeposit && o.Accepted > DateTime.Today && o.BotId == 14 && o.UserId == 1 && o.Id == 0 && o.TotalValue == new decimal(196.91) ), A <ITransactionWrapper> ._)).MustHaveHappened(); A.CallTo(() => _fakedItemInOfferTransactionRepoService.InsertAsync(A <List <DatabaseModel.ItemInOfferTransaction> > .That.Matches(i => i.Where(o => o.OfferTransactionId == 75 && o.ItemDescriptionId == 1 && o.Value == new decimal(11.22)).ToList().Count == 2 && i.Where(o => o.OfferTransactionId == 75 && o.ItemDescriptionId == 3 && o.Value == new decimal(78.00)).ToList().Count == 1 && i.Where(o => o.OfferTransactionId == 75 && o.ItemDescriptionId == 4 && o.Value == new decimal(5.47)).ToList().Count == 1 && i.Where(o => o.OfferTransactionId == 75 && o.ItemDescriptionId == 2 && o.Value == new decimal(45.5)).ToList().Count == 2 ), A <ITransactionWrapper> ._)).MustHaveHappened(); A.CallTo(() => _fakedTransactionWrapper.Commit()).MustHaveHappened(); }
private async Task <DatabaseModel.OfferTransaction> InsertTransactionOfferAndItemsInTransactionOffer ( ITransactionWrapper transactionWrapper, DatabaseModel.OfferTransaction offerTransactions, List <DatabaseModel.ItemInOfferTransaction> itemsInOffer ) { var offerInsertResponse = await _offerRepoService.InsertAsync(offerTransactions, transactionWrapper); foreach (var itemInOfferTransaction in itemsInOffer) { itemInOfferTransaction.OfferTransactionId = offerInsertResponse.Id; } await _itemInOfferTransactionRepoService.InsertAsync(itemsInOffer, transactionWrapper); transactionWrapper?.Commit(); return(offerInsertResponse); }