Example #1
0
        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]);
        }
Example #2
0
        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()));
        }
Example #3
0
        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());
        }
Example #4
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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"));
        }
Example #8
0
        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);
        }
Example #10
0
        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);
        }
Example #11
0
        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);
        }