Exemple #1
0
        public async Task LoadFolder_IgnoreTest()
        {
            var loader = new LocalFileSystemFileLoader(
                new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                { @"C:\page2.md", null },
                { @"C:\site\folder\page2.md", null },
                { @"C:\site\page1.md", null },
                { @"C:\site\page2.html", null },
                { @"C:\site\folder\1.txt", null },
                { @"C:\site\img\img1.png", null },
                { @"C:\site\img1\img1.png", null },
                { @"C:\site\test1.xlsx", null },
            }
                                   ), new Mock <Xarial.Docify.Base.Services.ILogger>().Object);

            var res = await loader.LoadFolder(Location.FromPath("C:\\site"),
                                              new string[]
            {
                "|*.txt",
                "|img\\*",
                "|test1.xlsx",
                "|*page2*"
            }).ToListAsync();

            Assert.AreEqual(2, res.Count());
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "page1.md"));
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "img1::img1.png"));
        }
Exemple #2
0
        public async Task LoadFolder_TextAndBinaryTest()
        {
            var loader = new LocalFileSystemFileLoader(
                new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                { @"C:\page2.md", null },
                { @"C:\site\page1.md", new MockFileData("abc") },
                { @"C:\site\page2.html", null },
                { @"C:\site\folder\1.txt", null },
                { @"C:\site\img\img1.png", new MockFileData(new byte[] { 1, 2, 3 }) },
                { @"C:\site\test1.xlsx", null },
            }
                                   ), new Mock <Xarial.Docify.Base.Services.ILogger>().Object);

            var res = await loader.LoadFolder(Location.FromPath("C:\\site"), null).ToListAsync();

            Assert.AreEqual(5, res.Count());
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "page1.md"));
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "page2.html"));
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "folder::1.txt"));
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "img::img1.png"));
            Assert.IsNotNull(res.FirstOrDefault(f => f.Location.ToId() == "test1.xlsx"));
            Assert.AreEqual("abc", res.FirstOrDefault(f => f.Location.ToId() == "page1.md").AsTextContent());
            Assert.IsTrue(new byte[] { 1, 2, 3 }.SequenceEqual(res.FirstOrDefault(f => f.Location.ToId() == "img::img1.png").Content));
        }
Exemple #3
0
        public void LoadFolder_MissingLocation()
        {
            var loader = new LocalFileSystemFileLoader(
                new MockFileSystem(new Dictionary <string, MockFileData>()
            {
                { @"C:\page2.md", null },
                { @"C:\site\folder\page2.md", null }
            }), new Mock <Xarial.Docify.Base.Services.ILogger>().Object);

            Assert.Throws <MissingLocationException>(() => loader.LoadFolder(Location.FromPath("C:\\site1"), null).ToEnumerable().ToList());
        }