public void Buy_Token_Buying_Success() { SetupMessage(creator, 0); var store = new NFTStore(mContractState.Object); var saleInfo = new SaleInfo { Price = 100, Seller = tokenOwner }; SetSaleInfo(saleInfo); SetupMessage(buyer, 100); SetupSafeTransferToken(contract, buyer, tokenId, TransferResult.Succeed()); SetupTransfer(tokenOwner, 100, TransferResult.Succeed()); store.Buy(tokenContract, tokenId); VerifyLog(new TokenPurchasedLog { Contract = tokenContract, TokenId = tokenId, Seller = tokenOwner, Buyer = buyer }); store.GetSaleInfo(tokenContract, tokenId) .Should() .Be(default(SaleInfo)); }
public void CancelSale_Success() { SetupMessage(creator, 0); var store = new NFTStore(mContractState.Object); var saleInfo = new SaleInfo { Price = 100, Seller = tokenOwner }; SetSaleInfo(saleInfo); SetupMessage(tokenOwner, 0); SetupSafeTransferToken(contract, tokenOwner, tokenId, TransferResult.Succeed()); store.CancelSale(tokenContract, tokenId); store.GetSaleInfo(tokenContract, tokenId) .Should() .Be(default(SaleInfo)); VerifyLog(new TokenSaleCanceledLog { Contract = tokenContract, TokenId = tokenId, Seller = tokenOwner }); }
public void OnNonFungibleTokenReceived_Operator_Mint_And_Sell_Token_Success() { SetupMessage(creator, 0); var store = new NFTStore(mContractState.Object); SetupMessage(tokenContract, 0); SetupGetOwnerOfToken(TransferResult.Succeed(contract)); var price = 5_00_000_000ul; var priceBytes = BitConverter.GetBytes(price); mSerializer.Setup(m => m.ToUInt64(priceBytes)).Returns(price); store.OnNonFungibleTokenReceived(operatorAddress, Address.Zero, tokenId, priceBytes) .Should() .BeTrue(); store.GetSaleInfo(tokenContract, tokenId) .Should() .Be(new SaleInfo { Price = price, Seller = operatorAddress }); VerifyLog(new TokenOnSaleLog { Contract = tokenContract, TokenId = tokenId, Seller = operatorAddress, Operator = operatorAddress, Price = price }); }