public void CollectJsonData_HasArrayValue_DataMerged() { var firstData = "{\"library\":{\"days\":[\"1\",\"2\"]}}"; var secondData = "{\"library\":{\"days\":[\"o:e\",\"two\"]}}"; var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); first.CollectJsonData(firstData.ToString()); first.CollectJsonData(secondData.ToString()); var second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = (DynamicJson)DynamicJson.Parse(second.GetLibraryData()); Assert.AreEqual("o:e", j.library.days[0]); Assert.AreEqual("two", j.library.days[1]); }
public void GetAllData_LocalOnly_ReturnLocal() { var c = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = new DynamicJson(); j.one = 1; c.CollectJsonData(j.ToString()); Assert.AreEqual(j, DynamicJson.Parse(c.GetAllData())); }
public void GetLibraryData_NoGlobalData_Empty() { var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = new DynamicJson(); j.one = 1; first.CollectJsonData(j.ToString()); Assert.AreEqual("{}", first.GetLibraryData()); }
public void WhenCollectedNoGlobalDataThenGlobalDataIsEmpty() { var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = new DynamicJson(); j.one = 1; first.CollectJsonData(j.ToString()); Assert.AreEqual(j, DynamicJson.Parse(first.LocalData)); }
public void WhenCollectedNoLocalDataThenLocalDataIsEmpty() { var first = new Configurator(_libraryFolder.Path); dynamic j = new DynamicJson(); j.library = new DynamicJson(); j.library.librarystuff = "foo"; first.CollectJsonData(j.ToString()); AssertEmpty(first.LocalData); }
public void WhenCollectedNoLocalDataThenLocalDataIsEmpty() { var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); var stringRep = DynamicJson.Serialize(new { library = new { librarystuff = "foo" } }); first.CollectJsonData(stringRep.ToString()); AssertEmpty(first.LocalData); }
public void ShowConfigureDialog() { var c = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); var stringRep = DynamicJson.Serialize(new { library = new { calendar = new { year = "2088" } } }); c.CollectJsonData(stringRep); c.ShowConfigurationDialog(Get_NotYetConfigured_CalendardBookStorage().FolderPath); Assert.IsTrue(c.GetLibraryData().Contains("year")); }
public void CollectJsonData_NewTopLevelData_DataMerged() { var firstData = DynamicJson.Serialize(new { library = new { one = "1", color = "red" } }); var secondData = DynamicJson.Serialize(new { library = new { two = "2", color = "blue" } }); var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); first.CollectJsonData(firstData.ToString()); first.CollectJsonData(secondData.ToString()); var second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = (DynamicJson)DynamicJson.Parse(second.GetLibraryData()); Assert.AreEqual("2", j.library.two); Assert.AreEqual("1", j.library.one); Assert.AreEqual("blue", j.library.color); }
public void CollectJsonData_NewArrayItems_DataMerged() { var firstData = DynamicJson.Serialize(new { library = new { food = new { veg = "v", fruit = "f" } } }); var secondData = DynamicJson.Serialize(new { library = new { food = new { bread = "b", fruit = "f" } } }); var first = new Configurator(_libraryFolder.Path, new NavigationIsolator()); first.CollectJsonData(firstData.ToString()); first.CollectJsonData(secondData.ToString()); var second = new Configurator(_libraryFolder.Path, new NavigationIsolator()); dynamic j = (DynamicJson)DynamicJson.Parse(second.GetLibraryData()); Assert.AreEqual("v", j.library.food.veg); Assert.AreEqual("f", j.library.food.fruit); Assert.AreEqual("b", j.library.food.bread); }
public void LibrarySettingsAreRoundTriped() { var first = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); var stringRep = DynamicJson.Serialize(new { library = new { stuff = "foo" } }); first.CollectJsonData(stringRep.ToString()); var second = new Configurator(_libraryFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = (DynamicJson)DynamicJson.Parse(second.GetLibraryData()); Assert.AreEqual("foo", j.library.stuff); }
public void CollectJsonData_NewArrayItems_DataMerged() { var firstData = DynamicJson.Serialize(new { library = new { food = new { veg = "v", fruit = "f", nuts = "n" } } }); var secondData = DynamicJson.Serialize(new { library = new { food = new { bread = "b", fruit = "{f\\:", nuts = "\"nut\"" } } }); var first = new Configurator(_collectionFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); first.CollectJsonData(firstData.ToString()); first.CollectJsonData(secondData.ToString()); var second = new Configurator(_collectionFolder.Path, NavigationIsolator.GetOrCreateTheOneNavigationIsolator()); dynamic j = (DynamicJson)DynamicJson.Parse(second.GetCollectionData()); Assert.AreEqual("v", j.library.food.veg); Assert.AreEqual("{f\\:", j.library.food.fruit); Assert.AreEqual("b", j.library.food.bread); Assert.AreEqual("\"nut\"", j.library.food.nuts); }