コード例 #1
0
        public void RequestFilesFromThePagesFolder()
        {
            var files = new List <string>
            {
                "68AA2FE5-58F9-421A-9C1B-02254B953BC5.json"
            };

            String rootPath     = $"c:\\{string.Empty.GetRandom()}";
            String expectedPath = System.IO.Path.Combine(rootPath, "pages");

            var fileSystem        = new Mock <IFile>();
            var directoryProvider = new Mock <IDirectory>();

            directoryProvider.Setup(f => f.EnumerateFiles(expectedPath))
            .Returns(files).Verifiable();

            foreach (var file in files)
            {
                fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>()))
                .Returns("{}");
            }

            var target = new ContentRepositoryBuilder()
                         .AddDirectoryService(directoryProvider.Object)
                         .AddFileService(fileSystem.Object)
                         .Build($"Provider=this;{_connectionStringFilepathKey}={rootPath}");

            var pages = target.GetAllPages();

            fileSystem.VerifyAll();
        }
コード例 #2
0
        private static void ExecutePropertyTest(String expected, Func <ContentItem, string> fieldValueDelegate, String json)
        {
            var files = new List <string>
            {
                "68AA2FE5-58F9-421A-9C1B-02254B953BC5.json"
            };

            var fileSystem        = new Mock <IFile>();
            var directoryProvider = new Mock <IDirectory>();

            directoryProvider.Setup(f => f.EnumerateFiles(It.IsAny <string>()))
            .Returns(files);

            foreach (var file in files)
            {
                fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>()))
                .Returns(json);
            }

            var target = new ContentRepositoryBuilder()
                         .AddDirectoryService(directoryProvider.Object)
                         .AddFileService(fileSystem.Object)
                         .Build(_defaultConnection);

            var pages  = target.GetAllPages();
            var actual = pages.ToArray()[0];

            Assert.Equal(expected, fieldValueDelegate(actual));
        }
コード例 #3
0
        public void IgnoreFilesWithoutJsonExtension()
        {
            var files = new List <string>
            {
                "82B52DBC-9D33-4C9E-A933-AF515E4FF140",
                "28C65CCD-D504-44D3-A54B-9E3DBB163D43.json",
                "0F716B73-9A2F-46D9-A576-3CA03EB10327.ppt",
                "8EE89C80-760E-4980-B980-5A4B70A563E2.json",
                "39836B5E-C330-4670-9897-1CBF0851AB5B.txt",
                "68AA2FE5-58F9-421A-9C1B-02254B953BC5.json",
                "86F29FA4-29CD-4292-8000-CEAFEA7A2315.com"
            };

            var fileSystem        = new Mock <IFile>();
            var directoryProvider = new Mock <IDirectory>();

            directoryProvider.Setup(f => f.EnumerateFiles(It.IsAny <string>()))
            .Returns(files);

            foreach (var file in files)
            {
                fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>()))
                .Returns("{}");
            }

            var target = new ContentRepositoryBuilder()
                         .AddDirectoryService(directoryProvider.Object)
                         .AddFileService(fileSystem.Object)
                         .Build(_defaultConnection);

            var pages = target.GetAllPages();

            Assert.Equal(3, pages.Count());
        }
コード例 #4
0
        public void ReturnAllPagesIfAllAreValid()
        {
            var files = new List <string>
            {
                "28C65CCD-D504-44D3-A54B-9E3DBB163D43.json",
                "8EE89C80-760E-4980-B980-5A4B70A563E2.json",
                "68AA2FE5-58F9-421A-9C1B-02254B953BC5.json"
            };

            var directoryProvider = new Mock <IDirectory>();

            directoryProvider.Setup(f => f.EnumerateFiles(It.IsAny <string>()))
            .Returns(files);

            var fileSystem = new Mock <IFile>();

            foreach (var file in files)
            {
                fileSystem.Setup(f => f.ReadAllText(It.IsAny <string>()))
                .Returns("{}");
            }

            var target = new ContentRepositoryBuilder()
                         .AddDirectoryService(directoryProvider.Object)
                         .AddFileService(fileSystem.Object)
                         .Build(_defaultConnection);

            var pages = target.GetAllPages();

            Assert.Equal(files.Count(), pages.Count());
        }