public FormAccounting() : base() { InitializeComponent(); _DataHistory = new HistoricalAccountingData(); _CurrentDate = null; _FilePath = "<NONE>"; dataGridViewAccounting.SetUpTable(); dataGridViewFXMarket.SetUpTable(); dataGridViewAssetMarket.SetUpTable(); }
public void HistoricalAccountingData() { HistoricalAccountingData had = new HistoricalAccountingData(); had.SetCcyDB(GetCcyDB()); // Create AccData 1 FXMarket fx1 = Init.CreateFXMarket(); fx1.CcyRef = had.CcyDB.RefCcy; fx1.AddQuote(new CurrencyPair("GBP", "EUR"), 1.1); fx1.AddQuote(new CurrencyPair("GBP", "JPY"), 130); AssetMarket amkt1 = Init.CreateAssetMarket(); amkt1.AddQuote(new AssetCcyPair(new Asset("AAPL"), new Currency("USD")), 1234.56); amkt1.PopulateWithFXMarket(fx1); List <Category> list = new List <Category> { Init.CreateCategory1(), Init.CreateCategory2() }; AccountingData ad1 = new AccountingData(list, fx1, amkt1); had.AddData(new DateTime(2020, 1, 1), ad1); // Create AccData2 FXMarket fx2 = new FXMarket(); fx2.Copy(fx1); fx2.AddQuote(new CurrencyPair("EUR", "USD"), 1.2); fx2.AddQuote(new CurrencyPair("GBP", "EUR"), 1.15); AssetMarket amkt2 = new AssetMarket(); amkt2.Copy(amkt1); amkt2.AddQuote(new AssetCcyPair(new Asset("BNP"), new Currency("EUR")), 50.0); amkt2.PopulateWithFXMarket(fx2); AccountingData ad2 = new AccountingData(list, fx2, amkt2); had.AddData(new DateTime(2020, 2, 3), ad2); // Test string fileName = SerializeObject(had, "HistoricalAccountingData"); HistoricalAccountingData desHad = DeserializeObject <HistoricalAccountingData>(fileName); Assert.IsTrue(had == desHad); }