public async void ShouldGetPoBySellerAndQuote() { // Prepare a new PO and create it var quoteId = GetRandomInt(); Buyer.Po poAsRequested = await CreateBuyerPoAsync(quoteId); var signature = poAsRequested.GetSignatureBytes(_contracts.Web3); await PrepSendFundsToBuyerWalletForPo(_contracts.Web3, poAsRequested); var txReceiptCreate = await _contracts.Deployment.BuyerWalletService.CreatePurchaseOrderRequestAndWaitForReceiptAsync(poAsRequested, signature); txReceiptCreate.Status.Value.Should().Be(1); // Get the PO number that was assigned var logPoCreated = txReceiptCreate.DecodeAllEvents <PurchaseOrderCreatedLogEventDTO>().FirstOrDefault(); logPoCreated.Should().NotBeNull(); var poNumberAsBuilt = logPoCreated.Event.Po.PoNumber; // Retrieve PO as-built using Seller and Quote, and check var poAsBuilt = (await _contracts.Deployment.BuyerWalletService.GetPoByEshopIdAndQuoteQueryAsync( poAsRequested.EShopId, quoteId)).Po; CheckCreatedPoFieldsMatch(poAsRequested.ToStoragePo(), poAsBuilt.ToStoragePo(), poNumberAsBuilt); }
public async void ShouldCreatePoAndRetrieveItBySellerAndQuote() { // Prepare a new PO and create it Buyer.Po poAsRequested = await CreateBuyerPoAsync(quoteId : GetRandomInt()); var signature = poAsRequested.GetSignatureBytes(_contracts.Web3); await PrepSendFundsToBuyerWalletForPo(_contracts.Web3, poAsRequested); var txReceipt = await _contracts.Deployment.BuyerWalletService.CreatePurchaseOrderRequestAndWaitForReceiptAsync(poAsRequested, signature); txReceipt.Status.Value.Should().Be(1); // Check PO create events var logPoCreateRequest = txReceipt.DecodeAllEvents <PurchaseOrderCreateRequestLogEventDTO>().FirstOrDefault(); logPoCreateRequest.Should().NotBeNull(); // <= PO as requested var logPoCreated = txReceipt.DecodeAllEvents <PurchaseOrderCreatedLogEventDTO>().FirstOrDefault(); logPoCreated.Should().NotBeNull(); // <= PO as built var poNumberAsBuilt = logPoCreated.Event.Po.PoNumber; // Retrieve the as-built PO var poAsBuilt = (await _contracts.Deployment.BuyerWalletService.GetPoByEshopIdAndQuoteQueryAsync( poAsRequested.EShopId, poAsRequested.QuoteId)).Po; // Most fields should be the same between poAsRequested and poAsBuilt (contract adds some fields to the poAsBuilt, e.g. it assigns the poNumber) CheckCreatedPoFieldsMatch(poAsRequested.ToStoragePo(), poAsBuilt.ToStoragePo(), poNumberAsBuilt); // Info DisplayPoHeader(_output, poAsBuilt.ToStoragePo()); }