Exemple #1
0
        static void TestMethod_SyncConfiguration_Serialize()
        {
            var config = new SyncConfiguration();

            config.m_src          = "chg8";
            config.m_destination  = "chg9";
            config.m_excludeDirs  = "chg10";
            config.m_excludeFiles = "chg11";
            config.m_mirror       = false;
            config.m_copySubDirsAndEmptySubdirs = true;
            config.m_copyFlags          = "#1@";
            config.m_directoryCopyFlags = "#2@";
            config.m_ipg                = "#3@";
            config.m_nRetries           = "#4@";
            config.m_waitBetweenRetries = "#5@";
            config.m_nThreads           = "#6@";
            config.m_custom             = "#7@";
            config.m_symlinkNotTarget   = false;
            config.m_fatTimes           = true;
            config.m_compensateDst      = false;
            File.Delete(Testing.GetTestTempFile("test_cfg_02_got.xml"));
            SyncConfiguration.Serialize(config, Testing.GetTestTempFile("test_cfg_02_got.xml"));
            string sExpected = File.ReadAllText(Testing.GetTestFile("test_cfg_02.xml"));
            string sGot      = File.ReadAllText(Testing.GetTestTempFile("test_cfg_02_got.xml"));

            sGot      = sGot.Replace("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"");
            sExpected = sExpected.Replace("\r", "").Replace("\n", "").Replace("  <", "<");
            sGot      = sGot.Replace("\r", "").Replace("\n", "").Replace("  <", "<");
            Utils.AssertEq(sExpected, sGot);
        }
        static void Test_SaveFromUIElements(FormSyncMain form)
        {
            var prevConfig = form.GetCurrentConfigFromUI();
            var config1    = SyncConfiguration.Deserialize(Testing.GetTestFile("test_cfg_01.xml"));

            form.SetCurrentConfigToUI(config1);
            var config2 = SyncConfiguration.Deserialize(Testing.GetTestFile("test_cfg_02.xml"));

            Test_SetUIElements(config2, form);
            var config2FromForm = form.GetCurrentConfigFromUI();

            File.Delete(Testing.GetTestTempFile("test_cfg_02_got.xml"));
            SyncConfiguration.Serialize(config2FromForm, Testing.GetTestTempFile("test_cfg_02_got.xml"));
            string sExpected = File.ReadAllText(Testing.GetTestFile("test_cfg_02.xml"));
            string sGot      = File.ReadAllText(Testing.GetTestTempFile("test_cfg_02_got.xml"));

            form.SetCurrentConfigToUI(prevConfig);
        }