public void ParseData_InvalidDataTooShort_ThrowsException() { byte[] data; data = HelperFunctions.ConvertHex(cDATA_INVALID); TransactionParser.Parse(data); }
public void ParserParsesDebitTransaction() { var parser = new TransactionParser(TransactionTestData.ValidTransactionLineWithDebitAmount); var transactions = parser.Parse(); Assert.AreEqual(-3.52M, transactions[0].Amount); }
public void ParserCanParseMultipleTransactions() { var parser = new TransactionParser(TransactionTestData.TwoValidTransactions); var transactions = parser.Parse(); Assert.AreEqual(2, transactions.Count); }
public IList <ITransaction> GetTransactionHistory(string address, int num) { IList <ITransaction> result = new List <ITransaction>(); if (num <= 0) { return(result); } string url = string.Format("{0}/transactions/address/{1}/limit/{2}", NodeUrl, address, num); string json = HttpHelper.Get(url); try { List <List <object> > list = JsonConvert.DeserializeObject <List <List <object> > >(json); if (list.Count == 0) { return(result); } List <object> txList = list[0]; foreach (object txObj in txList) { string txStr = JsonConvert.SerializeObject(txObj); ITransaction tx = TransactionParser.Parse(txStr); result.Add(tx); } } catch (Exception) { throw ApiError.FromJson(json); } return(result); }
public void CanParseTransactionXml() { Transaction transaction = TransactionParser.Parse(_xml); CheckIf.EqualId("419124c2108f39c94378c488dda67348", transaction.Id, "Transaction id should be parsed"); Assert.AreEqual("RUB", transaction.Currency, "Transaction currency should be parsed"); Assert.AreEqual( new DateTimeOffset(2013, 12, 9, 23, 00, 00, new TimeSpan(3, 0, 0)), transaction.Posted, "Transaction posted date should be parsed"); Assert.AreEqual( new DateTimeOffset(2014, 1, 6, 15, 30, 21, new TimeSpan(3, 0, 0)), transaction.Entered, "Transaction entered date should be parsed"); Assert.AreEqual("Обои (отдавать маме)", transaction.Description, "Transaction description should be parsed"); Assert.AreEqual(2, transaction.Splits.Count, "Transaction splits should be parsed"); AssertSplitValues( "e739f02a5e4ced52a8974292d183727f", "b43f593c319ae9bf475ddb2af3953b38", 10000.00m, 10000.00m, transaction.Splits[0]); AssertSplitValues( "0db32508c93b252e0acb168787d82289", "f7e5c9bd34d8cd881f481d837d98f94d", -10000.00m, -10000.00m, transaction.Splits[1]); }
public void ParserThrowsArgumentExceptionWhenParsingEmptyTransactions(string invalidInputTransaction) { var parser = new TransactionParser(invalidInputTransaction); _ = Assert.Throws <ArgumentException>( delegate { parser.Parse(); }); }
public void ParserParsesDescription() { var parser = new TransactionParser(TransactionTestData.ValidTransactionLineWithDebitAmount); var transactions = parser.Parse(); Assert.AreEqual("ACME Company", transactions[0].Description); }
public void ParserSkipsEmptyLine() { var parser = new TransactionParser(TransactionTestData.ValidTransactionLineWithDebitAmount + Environment.NewLine); var transactions = parser.Parse(); Assert.AreEqual(1, transactions.Count); }
public void ParserReadsLine() { var parser = new TransactionParser(TransactionTestData.ValidTransactionLineWithDebitAmount); var transactions = parser.Parse(); Assert.AreEqual(1, transactions.Count); }
public void ParseStream_EmptyData_ThrowsException() { MemoryStream stream = new MemoryStream { Capacity = 0 }; TransactionParser.Parse(stream); }
public void ParserParsesTransactionDate() { var parser = new TransactionParser(TransactionTestData.ValidTransactionLineWithDebitAmount); var transactions = parser.Parse(); Assert.AreEqual(new DateTime(2020, 12, 18), transactions[0].Date); }
public void ParseStream_InvalidDataTooShort_ThrowsException() { byte[] data; MemoryStream stream; data = HelperFunctions.ConvertHex(cDATA_INVALID); stream = new MemoryStream(data); TransactionParser.Parse(stream); }
public void ParseData_ValidData_IsValid() { byte[] data; Transaction result; data = HelperFunctions.ConvertHex(cDATA_VALID_1_1); result = TransactionParser.Parse(data); Assert.IsNotNull(result); Assert.AreEqual(result.Inputs.Count, 1); Assert.AreEqual(result.LockTime.Type, LockTimeType.NoLockTime); Assert.AreEqual(result.Outputs.Count, 1); Assert.AreEqual(result.Version, 1); }
public ITransaction GetUnconfirmedTransactionById(string txId) { string url = string.Format("{0}/transactions/unconfirmed/info/{1}", NodeUrl, txId); string json = HttpHelper.Get(url); try { return(TransactionParser.Parse(json)); } catch (Exception) { throw TransactionError.FromJson(json); } }
public ITransaction GetTransactionById(string txId) { string url = string.Format("{0}/transactions/info/{1}", NodeUrl, txId); string json = HttpHelper.Get(url); ITransaction tx; try { tx = TransactionParser.Parse(json); } catch (Exception) { throw TransactionError.FromJson(json); } if (tx != null && tx.Status.Equals("error")) { throw TransactionError.FromJson(json); } return(tx); }
public void ParseData_EmptyData_ThrowsException() { TransactionParser.Parse(new byte[0]); }
public void ParseData_NullData_ThrowsException() { TransactionParser.Parse(null as byte[]); }
public void ParseStream_NullData_ThrowsException() { TransactionParser.Parse(null as Stream); }