Exemplo n.º 1
0
        public void TestGetRegexFromDateUnitUndefined()
        {
            string dateFormat = "";

            Assert.AreEqual(FileSync.GetRegexFromDateUnit("f", ref dateFormat), "f");
            Assert.AreEqual(dateFormat, "'f'&");

            dateFormat = "";
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("ff", ref dateFormat), "ff");
            Assert.AreEqual(dateFormat, "'ff'&");

            dateFormat = "";
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("asdf", ref dateFormat), "asdf");
            Assert.AreEqual(dateFormat, "'asdf'&");

            dateFormat = "";
            Assert.AreEqual(FileSync.GetRegexFromDateUnit(" ", ref dateFormat), @"\ ");
            Assert.AreEqual(dateFormat, "' '&");

            dateFormat = "";
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("*", ref dateFormat), @"\*");
            Assert.AreEqual(dateFormat, "'*'&");

            dateFormat = "";
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("#", ref dateFormat), @"\#");
            Assert.AreEqual(dateFormat, "'#'&");
        }
Exemplo n.º 2
0
        public void TestGetRegexFromDateUnitDictionary()
        {
            string dateFormat = "";

            Assert.AreEqual(FileSync.GetRegexFromDateUnit("yyyy", ref dateFormat), @"\d{4}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("h", ref dateFormat), @"\d{1,2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("HH", ref dateFormat), @"\d{2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("H", ref dateFormat), @"\d{1,2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("mm", ref dateFormat), @"\d{2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("m", ref dateFormat), @"\d{1,2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("ss", ref dateFormat), @"\d{2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("s", ref dateFormat), @"\d{1,2}");
            Assert.AreEqual(FileSync.GetRegexFromDateUnit("tt", ref dateFormat), @"[AP]M");
            Assert.AreEqual(dateFormat, @"yyyy&h&HH&H&mm&m&ss&s&tt&");
        }