Example #1
0
 public void SetUp()
 {
     Engine = new Engine();
     Engine.FileSystem.FileProviders.Add(NormalizedPath.DefaultFileProvider.Scheme, GetFileProvider());
     Engine.FileSystem.RootPath = "/";
     Engine.FileSystem.InputPaths.Clear();
     Engine.FileSystem.InputPaths.Add("/TestFiles/Input");
     Pipeline = new ExecutionPipeline("Pipeline", (IModuleList)null);
     Context  = new ExecutionContext(Engine, Guid.Empty, Pipeline);
     Inputs   = new[] { Context.GetDocument() };
 }
Example #2
0
 public void SetUp()
 {
     Engine = new Engine();
     Engine.FileSystem.FileProviders.Add(NormalizedPath.DefaultFileProvider.Scheme, GetFileProvider());
     Engine.FileSystem.RootPath = "/";
     Engine.FileSystem.InputPaths.Clear();
     Engine.FileSystem.InputPaths.Add("/TestFiles/Input");
     Pipeline = new Pipeline("Pipeline", null);
     Context = new ExecutionContext(Engine, Pipeline);
     Inputs = new[] { Context.GetDocument() };
 }
Example #3
0
 public void SetUp()
 {
     Engine = new Engine();
     Engine.FileSystem.FileProviders.Add(string.Empty, GetFileProvider());
     Engine.FileSystem.RootPath = "/";
     Engine.FileSystem.InputPaths.Clear();
     Engine.FileSystem.InputPaths.Add("/TestFiles/Input");
     Pipeline = new Pipeline("Pipeline", null);
     Context  = new ExecutionContext(Engine, Pipeline);
     Inputs   = new[] { Context.GetDocument() };
 }
Example #4
0
            public void SitemapGeneratedWithSitemapItemAsString(string hostname, string formatterString, string expected)
            {
                // Given
                Engine engine = new Engine();

                if (!string.IsNullOrWhiteSpace(hostname))
                {
                    engine.Settings[Keys.Host] = hostname;
                }
                ExecutionPipeline contentPipeline = new ExecutionPipeline("Content", (IModuleList)null);
                IExecutionContext context         = new ExecutionContext(engine, Guid.Empty, contentPipeline);

                IDocument doc = context.GetDocument(context.GetContentStream("Test"), new[]
                {
                    new KeyValuePair <string, object>(Keys.RelativeFilePath, "sub/testfile.html")
                });

                IDocument[] inputs = { doc };

                Core.Modules.Metadata.Meta m = new Core.Modules.Metadata.Meta(
                    Keys.SitemapItem,
                    (d, c) => d[Keys.RelativeFilePath].ToString());
                var outputs = m.Execute(inputs, context);

                Func <string, string> formatter = null;

                if (!string.IsNullOrWhiteSpace(formatterString))
                {
                    formatter = f => string.Format(formatterString, f);
                }

                // When
                Sitemap          sitemap = new Sitemap(formatter);
                List <IDocument> results = sitemap.Execute(outputs.ToList(), context).ToList();

                foreach (IDocument document in inputs.Concat(outputs.ToList()))
                {
                    ((IDisposable)document).Dispose();
                }

                // Then
                Assert.AreEqual(1, results.Count);
                Assert.That(results[0].Content, Does.Contain($"<loc>{expected}</loc>"));
            }
Example #5
0
            public void SitemapGeneratedWithSitemapItemAsString(string hostname, string formatterString, string expected)
            {
                // Given
                Engine engine = new Engine();
                if (!string.IsNullOrWhiteSpace(hostname))
                {
                    engine.Settings.Host = hostname;
                }
                Pipeline contentPipeline = new Pipeline("Content", null);
                IExecutionContext context = new ExecutionContext(engine, contentPipeline);

                IDocument doc = context.GetDocument("Test", new[]
                {
                    new KeyValuePair<string, object>(Keys.RelativeFilePath, "sub/testfile.html")
                });
                IDocument[] inputs = {doc};

                Core.Modules.Metadata.Meta m = new Core.Modules.Metadata.Meta(Keys.SitemapItem,
                    (d, c) => d[Keys.RelativeFilePath].ToString());
                var outputs = m.Execute(inputs, context);

                Func<string, string> formatter = null;

                if (!string.IsNullOrWhiteSpace(formatterString))
                    formatter = f => string.Format(formatterString, f);

                // When
                Sitemap sitemap = new Sitemap(formatter);
                List<IDocument> results = sitemap.Execute(outputs.ToList(), context).ToList();

                foreach (IDocument document in inputs.Concat(outputs.ToList()))
                {
                    ((IDisposable) document).Dispose();
                }

                // Then
                Assert.AreEqual(1, results.Count);
                Assert.That(results[0].Content, Does.Contain($"<loc>{expected}</loc>"));
            }