GetAbsoluteHref() private method

private GetAbsoluteHref ( [ href, [ source = null ) : Uri
href [
source [
return System.Uri
コード例 #1
0
        //--------------------//

        #region Normalize
        /// <inheritdoc/>
        public override void Normalize(FeedUri feedUri = null)
        {
            base.Normalize(feedUri);

            if (Href != null)
            {
                Href = ModelUtils.GetAbsoluteHref(Href, feedUri);
            }
        }
コード例 #2
0
        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.");
        }
コード例 #3
0
        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.");
        }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
 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/")));
 }