public void TestDCRestore() { var directoryInfo = new DirectoryInfo("TestCsv"); var csvConfig = new CsvConfig(directoryInfo.FullName, reportException: reportException); directoryInfo.Refresh(); if (directoryInfo.Exists) { directoryInfo.Delete(recursive: true); directoryInfo.Refresh(); } directoryInfo.Create(); directoryInfo.Refresh(); try { var dc = new DC(csvConfig); var testParent0 = new TestParent("TestParent0"); var testParent1 = new TestParent("TestParent1"); var testParent2 = new TestParent("TestParent2"); var testChild0 = new TestChild("TestChild0", testParent0); var testChild1 = new TestChild("TestChild1", testParent2); var testChild2 = new TestChild("TestChild2", testParent0); testChild1.Release(); testParent2.Release(); testChild2.Update("TestChild2 updated", testParent1); var expectedTestParent0 = testParent0.ToString(); var expectedTestParent1 = testParent1.ToString(); var expectedTestChild0 = testChild0.ToString(); var expectedTestChild2 = testChild2.ToString(); dc.Dispose(); File.Delete(directoryInfo.FullName + @"\TestParent.csv"); File.Move(directoryInfo.FullName + @"\TestParent.bak", directoryInfo.FullName + @"\TestParent.csv"); File.Delete(directoryInfo.FullName + @"\TestChild.csv"); File.Move(directoryInfo.FullName + @"\TestChild.bak", directoryInfo.FullName + @"\TestChild.csv"); dc = new DC(csvConfig); Assert.AreEqual(expectedTestParent0, dc.TestParents[0].ToString()); Assert.AreEqual(expectedTestParent1, dc.TestParents[1].ToString()); Assert.AreEqual(expectedTestChild0, dc.TestChildren[0].ToString()); Assert.AreEqual(expectedTestChild2, dc.TestChildren[2].ToString()); } finally { DC.Data?.Dispose(); } }
public static void Main(string[] args) { var directoryInfo = new DirectoryInfo("SampleDataCsv"); if (directoryInfo.Exists) { directoryInfo.Delete(recursive: true); directoryInfo.Refresh(); } directoryInfo.Create(); var dc = new DC(new CsvConfig(directoryInfo.FullName, reportException: reportException)); Console.WriteLine("StorageLib Sample Data"); Console.WriteLine("======================"); Console.WriteLine(); Console.WriteLine("Directory: " + directoryInfo.FullName); try { #region DataModel Data Types // -------------------- var dataModelDataTypes = new DataModelDataTypes( date: new DateTime(9999, 12, 21), time: new TimeSpan(23, 59, 59), dateMinutes: new DateTime(9999, 12, 21, 23, 59, 0), dateSeconds: new DateTime(9999, 12, 21, 23, 59, 59), dateTimeTicks: DateTime.MaxValue, timeSpanTicks: TimeSpan.MaxValue, decimal_: decimal.MaxValue, decimal2: 123456789.12m, decimal4: 123456789.1234m, decimal5: 123456789.12345m, bool_: true, int_: int.MaxValue, long_: long.MaxValue, char_: char.MaxValue, string_: "A String with Unicode char smiley ☺"); Console.WriteLine(); Console.WriteLine("DataModelDataTypes: " + dataModelDataTypes); #endregion } finally { dc.Dispose(); } }