示例#1
0
 public void TestPrettyUnescape()
 {
     Assert.AreEqual(
         FeedTest.Test1Uri,
         // Colon is preserved on POSIX systems but not on other OSes
         FeedUri.PrettyUnescape(UnixUtils.IsUnix ? "http:##0install.de#feeds#test#test1.xml" : "http%3a##0install.de#feeds#test#test1.xml"));
 }
示例#2
0
        public void TestToString()
        {
            Assert.AreEqual("http://0install.de/", new FeedUri("http://0install.de").ToStringRfc());
            Assert.AreEqual("http://0install.de/", new FeedUri("http://0install.de/").ToStringRfc());
            Assert.AreEqual("http://0install.de/feeds/test1.xml", new FeedUri("http://0install.de/feeds/test1.xml").ToStringRfc());
            Assert.AreEqual("https://0install.de/feeds/test1.xml", new FeedUri("https://0install.de/feeds/test1.xml").ToStringRfc());

            Assert.AreEqual("http://0install.de/feeds/my feed.xml", new FeedUri("http://0install.de/feeds/my feed.xml").ToString());
            Assert.AreEqual("http://0install.de/feeds/my feed.xml", new FeedUri("http://0install.de/feeds/my%20feed.xml").ToString());
            Assert.AreEqual("http://0install.de/feeds/my%20feed.xml", new FeedUri("http://0install.de/feeds/my feed.xml").ToStringRfc());
            Assert.AreEqual("http://0install.de/feeds/my%20feed.xml", new FeedUri("http://0install.de/feeds/my%20feed.xml").ToStringRfc());

            var absoluteUri = new FeedUri(WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");

            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.LocalPath);
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.ToString());
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.ToStringRfc());

            absoluteUri = new FeedUri(WindowsUtils.IsWindows ? "file:///C:/my%20feed.xml" : "file:///root/my%20feed.xml");
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.LocalPath);
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.ToString());
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml",
                actual: absoluteUri.ToStringRfc());

            if (WindowsUtils.IsWindows)
            {
                absoluteUri = new FeedUri(@"\\SERVER\C$\my feed.xml");
                Assert.AreEqual(
                    expected: @"\\server\C$\my feed.xml",
                    actual: absoluteUri.ToString());
                Assert.AreEqual(
                    expected: @"\\server\C$\my feed.xml",
                    actual: absoluteUri.ToStringRfc());

                absoluteUri = new FeedUri("file://SERVER/C$/my%20feed.xml");
                Assert.AreEqual(
                    expected: @"\\server\C$\my feed.xml",
                    actual: absoluteUri.ToString());
                Assert.AreEqual(
                    expected: @"\\server\C$\my feed.xml",
                    actual: absoluteUri.ToStringRfc());
            }
        }
示例#3
0
        public void TestPrefixes()
        {
            var fakeUri = new FeedUri("fake:http://example.com/");

            fakeUri.IsFake.Should().BeTrue();
            fakeUri.ToString().Should().Be("fake:http://example.com/");
            fakeUri.ToStringRfc().Should().Be("fake:http://example.com/");

            var fromDistributionUri = new FeedUri("distribution:http://example.com/");

            fromDistributionUri.IsFromDistribution.Should().BeTrue();
            fromDistributionUri.ToString().Should().Be("distribution:http://example.com/");
            fromDistributionUri.ToStringRfc().Should().Be("distribution:http://example.com/");
        }
示例#4
0
        internal string BuildPath(Icon icon)
        {
            string path = Path.Combine(_path, FeedUri.Escape(icon.Href.AbsoluteUri));

            void EnsureExtension(string mimeType, string extension)
            {
                if (icon.MimeType == mimeType && !StringUtils.EqualsIgnoreCase(Path.GetExtension(path), extension))
                {
                    path += extension;
                }
            }

            EnsureExtension(Icon.MimeTypePng, ".png");
            EnsureExtension(Icon.MimeTypeIco, ".ico");
            EnsureExtension(Icon.MimeTypeSvg, ".svg");

            return(path);
        }
示例#5
0
        public void TestToString()
        {
            new FeedUri("http://example.com").ToStringRfc().Should().Be("http://example.com/");
            new FeedUri("http://example.com/").ToStringRfc().Should().Be("http://example.com/");
            new FeedUri("http://example.com/test1.xml").ToStringRfc().Should().Be("http://example.com/test1.xml");
            new FeedUri("https://example.com/test1.xml").ToStringRfc().Should().Be("https://example.com/test1.xml");

            new FeedUri("http://example.com/my feed.xml").ToString().Should().Be("http://example.com/my feed.xml");
            new FeedUri("http://example.com/my%20feed.xml").ToString().Should().Be("http://example.com/my feed.xml");
            new FeedUri("http://example.com/my feed.xml").ToStringRfc().Should().Be("http://example.com/my%20feed.xml");
            new FeedUri("http://example.com/my%20feed.xml").ToStringRfc().Should().Be("http://example.com/my%20feed.xml");

            var absoluteUri = new FeedUri(WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");

            absoluteUri.LocalPath.Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");
            absoluteUri.ToString().Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");
            absoluteUri.ToStringRfc().Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");

            absoluteUri = new FeedUri(WindowsUtils.IsWindows ? "file:///C:/my%20feed.xml" : "file:///root/my%20feed.xml");
            absoluteUri.LocalPath.Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");
            absoluteUri.ToString().Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");
            absoluteUri.ToStringRfc().Should().Be(
                WindowsUtils.IsWindows ? @"C:\my feed.xml" : "/root/my feed.xml");

            if (WindowsUtils.IsWindows)
            {
                absoluteUri = new FeedUri(@"\\SERVER\C$\my feed.xml");
                absoluteUri.ToString().Should().Be(
                    @"\\server\C$\my feed.xml");
                absoluteUri.ToStringRfc().Should().Be(
                    @"\\server\C$\my feed.xml");

                absoluteUri = new FeedUri("file://SERVER/C$/my%20feed.xml");
                absoluteUri.ToString().Should().Be(
                    @"\\server\C$\my feed.xml");
                absoluteUri.ToStringRfc().Should().Be(
                    @"\\server\C$\my feed.xml");
            }
        }
示例#6
0
 /// <summary>
 /// Creates a new feed target.
 /// </summary>
 /// <param name="uri">The URI or local path (must be absolute) to the feed.</param>
 /// <param name="feed">The data aquired from <paramref name="uri"/>. <see cref="Feed.Normalize"/> has already been called.</param>
 public FeedTarget([NotNull] FeedUri uri, [NotNull] Feed feed)
 {
     Uri  = uri;
     Feed = feed;
 }
示例#7
0
 public void TestPrettyUnescape()
 => FeedUri.PrettyUnescape(UnixUtils.IsUnix ? "http:##example.com#test1.xml" : "http%3a##example.com#test1.xml").Should().Be(FeedTest.Test1Uri);
示例#8
0
 public void TestUnescape()
 => FeedUri.Unescape("http%3a%2f%2fexample.com%2Ftest1.xml").Should().Be(FeedTest.Test1Uri);
示例#9
0
 public void TestUnescape()
 {
     Assert.AreEqual(
         FeedTest.Test1Uri,
         FeedUri.Unescape("http%3A%2F%2F0install.de%2Ffeeds%2Ftest%2Ftest1.xml"));
 }
示例#10
0
 public void TestPrettyUnescape()
 {
     FeedUri.PrettyUnescape(UnixUtils.IsUnix ? "http:##0install.de#feeds#test#test1.xml" : "http%3a##0install.de#feeds#test#test1.xml").Should().Be(
         FeedTest.Test1Uri);
 }
示例#11
0
 public void TestUnescape()
 {
     FeedUri.Unescape("http%3A%2F%2F0install.de%2Ffeeds%2Ftest%2Ftest1.xml").Should().Be(FeedTest.Test1Uri);
 }