コード例 #1
0
ファイル: RedirectFixture.cs プロジェクト: glennawatson/Wyam
        public void WithAdditionalOutputWithoutMetaRefresh()
        {
            // Given
            TestDocument redirected1 = new TestDocument(new MetadataItems
            {
                { Keys.RedirectFrom, new List <FilePath> {
                      new FilePath("foo.html")
                  } },
                { Keys.RelativeFilePath, new FilePath("foo2.html") }
            });

            redirected1.AddTypeConversion <FilePath, string>(x => x.FullPath);
            TestDocument redirected2 = new TestDocument(new MetadataItems
            {
                { Keys.RedirectFrom, new List <FilePath> {
                      new FilePath("bar/baz.html")
                  } }
            });

            redirected2.AddTypeConversion <FilePath, string>(x => x.FullPath);
            IExecutionContext context  = new TestExecutionContext();
            Redirect          redirect = new Redirect()
                                         .WithAdditionalOutput(new FilePath("a/b"), x => string.Join("|", x.Select(y => $"{y.Key} {y.Value}")))
                                         .WithMetaRefreshPages(false);

            // When
            List <IDocument> results = redirect.Execute(new[] { redirected1, redirected2 }, context).ToList();  // Make sure to materialize the result list

            // Then
            CollectionAssert.AreEquivalent(new[] { "a/b" }, results.Select(x => x.Get <FilePath>(Keys.WritePath).FullPath));
        }
コード例 #2
0
            public void DoesNotChangeImageDomain()
            {
                // Given
                TestExecutionContext context = new TestExecutionContext();

                context.AddTypeConversion <string, Uri>(x => new Uri(x));
                context.Settings[Keys.Host] = "buzz.com";
                TestDocument document = new TestDocument(new Dictionary <string, object>
                {
                    { Keys.RelativeFilePath, new FilePath("fizz/buzz") },
                    { FeedKeys.Image, new Uri("http://foo.com/bar/baz.png") }
                });

                document.AddTypeConversion <Uri, string>(x => x.ToString());
                document.AddTypeConversion <FilePath, string>(x => x.FullPath);
                GenerateFeeds module = new GenerateFeeds();

                // When
                IList <IDocument> results = module.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                results.Select(x => x.FilePath(Keys.WritePath).FullPath).ShouldBe(new[] { "feed.rss", "feed.atom" }, true);
                results[0].Content.ShouldContain("http://foo.com/bar/baz.png");
            }