示例#1
0
        internal static void ExecuteTemplateContentTest(this String templateFilename, Enumerations.TemplateType templateType)
        {
            string expected = string.Empty.GetRandom();

            string templatePath = string.Empty.GetRandom();
            string expectedPath = System.IO.Path.Combine(templatePath, templateFilename);

            var mockFileService = new Mock <IFile>();

            mockFileService
            .Setup(f => f.ReadAllText(It.IsAny <String>()))
            .Returns(string.Empty.GetRandom());
            mockFileService
            .Setup(f => f.ReadAllText(expectedPath))
            .Returns(expected);

            var serviceProvider = new ServiceCollection()
                                  .AddFileService(mockFileService)
                                  .BuildServiceProvider();

            string connection = String.Format(_connectionFormat, templatePath);
            var    target     = new FileSystem.ReadRepository(serviceProvider, connection);
            var    actual     = target.GetAllTemplates();

            Assert.Equal(expected, actual.Single(t => t.TemplateType == templateType).Content);
        }
示例#2
0
        public void RetrieveEachTemplateExactlyOnceRegardlessOfHowManyTimesRequested()
        {
            string templatePath = string.Empty.GetRandom();
            string connection   = string.Format(_connectionFormat, templatePath);

            var mockFileService = new Mock <IFile>();

            mockFileService.ConfigureTemplate(templatePath, "Style.template.css");
            mockFileService.ConfigureTemplate(templatePath, "HomePage.template.html");
            mockFileService.ConfigureTemplate(templatePath, "ContentPage.template.html");
            mockFileService.ConfigureTemplate(templatePath, "SearchPage.template.html");
            mockFileService.ConfigureTemplate(templatePath, "PostPage.template.html");
            mockFileService.ConfigureTemplate(templatePath, "Redirect.template.html");
            mockFileService.ConfigureTemplate(templatePath, "Archive.template.html");
            mockFileService.ConfigureTemplate(templatePath, "ArchiveItem.template.html");
            mockFileService.ConfigureTemplate(templatePath, "Syndication.template.xml");
            mockFileService.ConfigureTemplate(templatePath, "SyndicationItem.template.xml");
            mockFileService.ConfigureTemplate(templatePath, "ContactPage.template.html");
            mockFileService.ConfigureTemplate(templatePath, "ContentItem.template.html");

            var serviceProvider = new ServiceCollection()
                                  .AddFileService(mockFileService)
                                  .BuildServiceProvider();

            var target = new FileSystem.ReadRepository(serviceProvider, connection);
            var actual = target.GetAllTemplates();

            actual = target.GetAllTemplates();

            mockFileService.VerifyOnce(templatePath, "Style.template.css");
            mockFileService.VerifyOnce(templatePath, "HomePage.template.html");
            mockFileService.VerifyOnce(templatePath, "ContentPage.template.html");
            mockFileService.VerifyOnce(templatePath, "SearchPage.template.html");
            mockFileService.VerifyOnce(templatePath, "PostPage.template.html");
            mockFileService.VerifyOnce(templatePath, "Redirect.template.html");
            mockFileService.VerifyOnce(templatePath, "Archive.template.html");
            mockFileService.VerifyOnce(templatePath, "ArchiveItem.template.html");
            mockFileService.VerifyOnce(templatePath, "Syndication.template.xml");
            mockFileService.VerifyOnce(templatePath, "SyndicationItem.template.xml");
            mockFileService.VerifyOnce(templatePath, "ContactPage.template.html");
            mockFileService.VerifyOnce(templatePath, "ContentItem.template.html");
        }
示例#3
0
        internal static void ExecuteTemplateRetrievalTest(this String templateFilename)
        {
            string templatePath = string.Empty.GetRandom();
            string expected     = System.IO.Path.Combine(templatePath, templateFilename);

            var mockFileService = new Mock <IFile>();

            mockFileService
            .Setup(f => f.ReadAllText(expected))
            .Returns(string.Empty.GetRandom())
            .Verifiable();

            var serviceProvider = new ServiceCollection()
                                  .AddFileService(mockFileService)
                                  .BuildServiceProvider();

            string connection = String.Format(_connectionFormat, templatePath);
            var    target     = new FileSystem.ReadRepository(serviceProvider, connection);
            var    actual     = target.GetAllTemplates();

            mockFileService.Verify();
        }