예제 #1
0
        public void CouldValidateDataPath()
        {
            Assert.IsTrue(DataPath.TryValidate("a/b/c", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("_", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("@a/b/", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("/a/b/@c/", out var rewritten, out _));
            Assert.AreEqual("@c/a/b", rewritten);
            Assert.IsTrue(DataPath.TryValidate("@my/a/b/", out rewritten, out _));
            Assert.AreEqual("~/a/b", rewritten);
            Assert.IsTrue(DataPath.TryValidate("~/a/b/", out _, out _));
            Assert.IsTrue(DataPath.TryValidate("sdvFSbdvfju.eegb.ewg-weg.___degewbg.dfs", out _, out _));


            Assert.IsTrue(DataPath.TryValidate("a.b", out _, out _));

            Assert.IsFalse(DataPath.TryValidate("~a/b/", out _, out _));
            Assert.IsFalse(DataPath.TryValidate(".", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("..", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("-", out _, out _));
            Assert.IsFalse(DataPath.TryValidate("--", out _, out _));
        }