public void SaveLedgersAndGetAllLedgersTest_SavesMultipleObjectInDatabase_ChecksIfTheOutputIsAsExpected() { Ledger ledger = new Ledger("1234", DateTime.Now, LedgerType.Trade, new Currency("XBT", true), 1000.543m, 0.005m, 23000, null, null, null, "deposit123", new AccountId(1)); _persistanceRepository.SaveOrUpdate(ledger); Thread.Sleep(1000); Ledger ledger2 = new Ledger("12345", DateTime.Now, LedgerType.Trade, new Currency("LTC", true), 2000.543m, 0.005m, 3000, null, null, null, "deposit123", new AccountId(1)); _persistanceRepository.SaveOrUpdate(ledger2); Thread.Sleep(1000); Ledger ledger3 = new Ledger("123456", DateTime.Now, LedgerType.Trade, new Currency("BTC", true), 3000.543m, 0.005m, 3000, null, null, null, "deposit123", new AccountId(1)); _persistanceRepository.SaveOrUpdate(ledger3); // Retreives the list in descending order of time IList <Ledger> retrievedLedgers = _ledgerRepository.GetAllLedgers(); Assert.IsNotNull(retrievedLedgers); Assert.AreEqual(3, retrievedLedgers.Count); Assert.AreEqual(ledger.Currency.Name, retrievedLedgers[0].Currency.Name); Assert.AreEqual(ledger.LedgerId, retrievedLedgers[0].LedgerId); Assert.AreEqual(ledger.LedgerType, retrievedLedgers[0].LedgerType); Assert.AreEqual(ledger.Amount, retrievedLedgers[0].Amount); Assert.AreEqual(ledger.Fee, retrievedLedgers[0].Fee); Assert.AreEqual(ledger.Balance, retrievedLedgers[0].Balance); Assert.AreEqual(ledger.TradeId, retrievedLedgers[0].TradeId); Assert.AreEqual(ledger.OrderId, retrievedLedgers[0].OrderId); Assert.AreEqual(ledger.AccountId.Value, retrievedLedgers[0].AccountId.Value); Assert.AreEqual(ledger2.Currency.Name, retrievedLedgers[1].Currency.Name); Assert.AreEqual(ledger2.LedgerId, retrievedLedgers[1].LedgerId); Assert.AreEqual(ledger2.LedgerType, retrievedLedgers[1].LedgerType); Assert.AreEqual(ledger2.Amount, retrievedLedgers[1].Amount); Assert.AreEqual(ledger2.Fee, retrievedLedgers[1].Fee); Assert.AreEqual(ledger2.Balance, retrievedLedgers[1].Balance); Assert.AreEqual(ledger2.TradeId, retrievedLedgers[1].TradeId); Assert.AreEqual(ledger2.OrderId, retrievedLedgers[1].OrderId); Assert.AreEqual(ledger2.AccountId.Value, retrievedLedgers[1].AccountId.Value); Assert.AreEqual(ledger3.Currency.Name, retrievedLedgers[2].Currency.Name); Assert.AreEqual(ledger3.LedgerId, retrievedLedgers[2].LedgerId); Assert.AreEqual(ledger3.LedgerType, retrievedLedgers[2].LedgerType); Assert.AreEqual(ledger3.Amount, retrievedLedgers[2].Amount); Assert.AreEqual(ledger3.Fee, retrievedLedgers[2].Fee); Assert.AreEqual(ledger3.Balance, retrievedLedgers[2].Balance); Assert.AreEqual(ledger3.TradeId, retrievedLedgers[2].TradeId); Assert.AreEqual(ledger3.OrderId, retrievedLedgers[2].OrderId); Assert.AreEqual(ledger3.AccountId.Value, retrievedLedgers[2].AccountId.Value); }
/// <summary> /// Gets all the ledgers /// </summary> /// <returns></returns> public IList <LedgerRepresentation> GetAllLedgers(int accountId) { IList <LedgerRepresentation> ledgerRepresentations = new List <LedgerRepresentation>(); IList <Ledger> ledgers = _ledgerRepository.GetAllLedgers(accountId); foreach (var ledger in ledgers) { ledgerRepresentations.Add(new LedgerRepresentation(ledger.LedgerId, ledger.DateTime, ledger.LedgerType.ToString(), ledger.Currency.Name, ledger.Amount, ledger.AmountInUsd, ledger.Fee, ledger.Balance, ledger.TradeId, ledger.OrderId, ledger.WithdrawId, ledger.DepositId, ledger.AccountId.Value)); } return(ledgerRepresentations); }