Пример #1
0
        public void TestEmbeddedResource()
        {
            var assembly = typeof(FileSystemTests).GetTypeInfo().Assembly;
            EmbeddedFileSystem fileSystem = new EmbeddedFileSystem(assembly, "OurPresence.Modeller.Liquid.Tests.Embedded");

            Assert.Equal(@"OurPresence.Modeller.Liquid.Tests.Embedded._mypartial.liquid", fileSystem.FullPath("mypartial"));
            Assert.Equal(@"OurPresence.Modeller.Liquid.Tests.Embedded.dir._mypartial.liquid", fileSystem.FullPath("dir/mypartial"));

            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("../dir/mypartial"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("/dir/../../dir/mypartial"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("/etc/passwd"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath(@"C:\mypartial"));
        }
Пример #2
0
        public void TestEmbeddedResource()
        {
            var assembly = Assembly.GetExecutingAssembly();
            EmbeddedFileSystem fileSystem = new EmbeddedFileSystem(assembly, "DotLiquid.Tests.Embedded");

            Assert.AreEqual(@"DotLiquid.Tests.Embedded._mypartial.liquid", fileSystem.FullPath("mypartial"));
            Assert.AreEqual(@"DotLiquid.Tests.Embedded.dir._mypartial.liquid", fileSystem.FullPath("dir/mypartial"));

            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("../dir/mypartial"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("/dir/../../dir/mypartial"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath("/etc/passwd"));
            Assert.Throws <FileSystemException>(() => fileSystem.FullPath(@"C:\mypartial"));
        }