public void TestGetAbsoluteHref() { var 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."); }
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/"))); }