public void PaymentOperation() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF KeyPair source = KeyPair.FromSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR KeyPair destination = KeyPair.FromSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII"); Asset asset = new Stellar.Asset(); long amount = 1000; PaymentOperation operation = new PaymentOperation.Builder(destination, asset, amount) .SetSourceAccount(source) .Build(); Assert.AreEqual(source.Address, operation.SourceAccount.Address); Assert.AreEqual(destination.Address, operation.Destination.Address); Assert.AreEqual(asset.Type, operation.Asset.Type); Assert.AreEqual(amount, operation.Amount); Assert.AreEqual( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAEAAAAA7eBSYbzcL5UKo7oXO24y1ckX+XuCtkDsyNHOp1n1bxAAAAAAAAAAAAAAA+g=", operation.ToXdrBase64()); Stellar.Generated.Operation xdr = operation.ToXDR(); PaymentOperation parsedOperation = Stellar.PaymentOperation.FromXDR(xdr); Assert.AreEqual(source.Address, parsedOperation.SourceAccount.Address); Assert.AreEqual(destination.Address, parsedOperation.Destination.Address); Assert.AreEqual(asset.Type, parsedOperation.Asset.Type); Assert.AreEqual(amount, parsedOperation.Amount); }
public void PaymentOperationNullSource() { // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR KeyPair destination = KeyPair.FromSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII"); Asset asset = new Stellar.Asset(); long amount = 1000; var ex = Assert.Throws <NullReferenceException>(() => new PaymentOperation.Builder(destination, asset, amount) .SetSourceAccount(null) .Build()); Assert.AreEqual(ex.Message, "sourceAccount cannot be null."); }
public void PaymentOperationNullDestination() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF KeyPair source = KeyPair.FromSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); Asset asset = new Stellar.Asset(); long amount = 1000; var ex = Assert.Throws <NullReferenceException>(() => new PaymentOperation.Builder(null, asset, amount) .SetSourceAccount(source) .Build()); Assert.AreEqual(ex.Message, "destination cannot be null."); }
public void PaymentOperationNegativeAmount() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF KeyPair source = KeyPair.FromSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); // GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR KeyPair destination = KeyPair.FromSeed("SDHZGHURAYXKU2KMVHPOXI6JG2Q4BSQUQCEOY72O3QQTCLR2T455PMII"); Asset asset = new Stellar.Asset(); var ex = Assert.Throws <ArgumentException>(() => new PaymentOperation.Builder(destination, asset, -1) .SetSourceAccount(source) .Build()); Assert.AreEqual(ex.Message, "amount must be non-negative."); }