public void Prefixes() { 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/"); }
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"); } }
public void TestToString() { new FeedUri("http://0install.de").ToStringRfc().Should().Be("http://0install.de/"); new FeedUri("http://0install.de/").ToStringRfc().Should().Be("http://0install.de/"); new FeedUri("http://0install.de/feeds/test1.xml").ToStringRfc().Should().Be("http://0install.de/feeds/test1.xml"); new FeedUri("https://0install.de/feeds/test1.xml").ToStringRfc().Should().Be("https://0install.de/feeds/test1.xml"); new FeedUri("http://0install.de/feeds/my feed.xml").ToString().Should().Be("http://0install.de/feeds/my feed.xml"); new FeedUri("http://0install.de/feeds/my%20feed.xml").ToString().Should().Be("http://0install.de/feeds/my feed.xml"); new FeedUri("http://0install.de/feeds/my feed.xml").ToStringRfc().Should().Be("http://0install.de/feeds/my%20feed.xml"); new FeedUri("http://0install.de/feeds/my%20feed.xml").ToStringRfc().Should().Be("http://0install.de/feeds/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"); } }
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/"); }
protected override async Task <IEnumerable <ReleaseInfo> > PerformQuery(TorznabQuery query) { var requestUri = FeedUri.ToString(); var qc = new NameValueCollection { { "apikey", configData.Key.Value }, { "limit", "100" }, { "extended", "1" }, }; if (query.IsTVSearch) { qc.Add("t", "tvsearch"); } else if (query.IsMovieSearch) { qc.Add("t", "movie"); } else { qc.Add("t", "search"); } if (!string.IsNullOrWhiteSpace(query.SearchTerm)) { qc.Add("q", query.SearchTerm); } var queryCats = new List <int>(); foreach (var queryCategory in query.Categories) { queryCats.Add(queryCategory); } if (queryCats.Any()) { qc.Add("cat", string.Join(",", queryCats)); } if (!string.IsNullOrWhiteSpace(query.ImdbID)) { qc.Add("imdbid", query.ImdbID); } if (query.TvdbID != null) { qc.Add("tvdbid", query.TvdbID.ToString()); } if (!string.IsNullOrWhiteSpace(query.Episode)) { qc.Add("ep", query.Episode); } if (query.Season > 0) { qc.Add("season", query.Season.ToString()); } requestUri = requestUri + "?" + qc.GetQueryString(); var request = new WebRequest { Url = requestUri, Type = RequestType.GET, Encoding = Encoding }; var result = await webclient.GetResultAsync(request); var results = ParseFeedForResults(result.ContentString); return(results); }
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()); } }