//--------------------// #region Normalize /// <inheritdoc/> public override void Normalize(FeedUri feedUri = null) { base.Normalize(feedUri); if (Href != null) { Href = ModelUtils.GetAbsoluteHref(Href, feedUri); } }
public void TestGetAbsoluteHref() { Uri absoluteHref = WindowsUtils.IsWindows ? new Uri("file:///C:/local/subdir/file") : new Uri("file:///local/subdir/file"); var result = ModelUtils.GetAbsoluteHref(new Uri("subdir/file", UriKind.Relative), new FeedUri(WindowsUtils.IsWindows ? @"C:\local\feed.xml" : "/local/feed.xml")); Assert.IsTrue(result.IsAbsoluteUri); Assert.AreEqual(absoluteHref, result); Assert.AreEqual(absoluteHref, ModelUtils.GetAbsoluteHref(absoluteHref), "Should ignore source if href is already absolute."); }
public void TestGetAbsoluteHref() { Uri absoluteHref = WindowsUtils.IsWindows ? new Uri("file:///C:/local/subdir/file") : new Uri("file:///local/subdir/file"); var result = ModelUtils.GetAbsoluteHref(new Uri("subdir/file", UriKind.Relative), new FeedUri(WindowsUtils.IsWindows ? @"C:\local\feed.xml" : "/local/feed.xml")); result.IsAbsoluteUri.Should().BeTrue(); result.Should().Be(absoluteHref); ModelUtils.GetAbsoluteHref(absoluteHref) .Should().Be(absoluteHref, because: "Should ignore source if href is already absolute."); }
/// <inheritdoc/> public override void Normalize(FeedUri feedUri) { #region Sanity checks if (feedUri == null) { throw new ArgumentNullException(nameof(feedUri)); } #endregion base.Normalize(feedUri); if (Href != null) { Href = ModelUtils.GetAbsoluteHref(Href, feedUri); } }
public void TestGetAbsoluteHrefException() { Assert.Throws <UriFormatException>(() => ModelUtils.GetAbsoluteHref(new Uri("subdir/file", UriKind.Relative))); Assert.Throws <UriFormatException>(() => ModelUtils.GetAbsoluteHref(new Uri("subdir/file", UriKind.Relative), new FeedUri("http://remote/"))); }