mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
ci/cd: fix whitespaces (#11749)
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Jackett.Test.Common.Helpers
|
||||
//https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=netcore-2.0
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
||||
_codePagesToTest = new []{
|
||||
_codePagesToTest = new[]{
|
||||
Encoding.UTF8,
|
||||
Encoding.ASCII,
|
||||
Encoding.GetEncoding("iso-8859-1"),
|
||||
@@ -26,7 +26,7 @@ namespace Jackett.Test.Common.Helpers
|
||||
Encoding.GetEncoding("windows-1251") }
|
||||
;
|
||||
|
||||
_stringsToTest = new []
|
||||
_stringsToTest = new[]
|
||||
{
|
||||
"Test! אני לא יודע עברית, אבל אני מאמין שזה טקסט חוקי! $ # 2 אני תוהה אם אמוג'י יהיה נתמך 🐀.",
|
||||
"Å[ÉfÉBÉìÉOÇÕìÔǵÇ≠ǻǢ",
|
||||
|
@@ -74,7 +74,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
|
||||
query = new TorznabQuery // with child category
|
||||
{
|
||||
Categories = new [] { TorznabCatType.MoviesSD.ID }
|
||||
Categories = new[] { TorznabCatType.MoviesSD.ID }
|
||||
};
|
||||
filteredResults = indexer._FilterResults(query, results).ToList();
|
||||
Assert.AreEqual(2, filteredResults.Count);
|
||||
@@ -83,7 +83,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
|
||||
query = new TorznabQuery // with parent category
|
||||
{
|
||||
Categories = new [] { TorznabCatType.Movies.ID }
|
||||
Categories = new[] { TorznabCatType.Movies.ID }
|
||||
};
|
||||
filteredResults = indexer._FilterResults(query, results).ToList();
|
||||
Assert.AreEqual(3, filteredResults.Count);
|
||||
@@ -93,7 +93,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
|
||||
query = new TorznabQuery // with custom category
|
||||
{
|
||||
Categories = new [] { 100004 }
|
||||
Categories = new[] { 100004 }
|
||||
};
|
||||
filteredResults = indexer._FilterResults(query, results).ToList();
|
||||
Assert.AreEqual(2, filteredResults.Count);
|
||||
@@ -207,7 +207,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
{
|
||||
var indexer = new TestWebIndexer();
|
||||
|
||||
indexer._AddMultiCategoryMapping(TorznabCatType.MoviesHD,19, 18);
|
||||
indexer._AddMultiCategoryMapping(TorznabCatType.MoviesHD, 19, 18);
|
||||
Assert.AreEqual(1, indexer.TorznabCaps.Categories.GetTorznabCategoryTree().Count);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
// you can find more complex tests in TorznabCapabilitiesCategoriesTests.cs
|
||||
var query = new TorznabQuery // int category with subcategories (parent cat)
|
||||
{
|
||||
Categories = new [] { TorznabCatType.Movies.ID }
|
||||
Categories = new[] { TorznabCatType.Movies.ID }
|
||||
};
|
||||
var trackerCats = indexer._MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(2, trackerCats.Count);
|
||||
|
@@ -15,7 +15,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
{
|
||||
var definition = new IndexerDefinition // minimun indexer definition
|
||||
{
|
||||
Links = new List<string>{ "https://example.com" },
|
||||
Links = new List<string> { "https://example.com" },
|
||||
Caps = new capabilitiesBlock
|
||||
{
|
||||
Modes = new Dictionary<string, List<string>>
|
||||
@@ -53,7 +53,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
|
||||
definition = new IndexerDefinition // test categories (same as in C# indexer)
|
||||
{
|
||||
Links = new List<string>{ "https://example.com" },
|
||||
Links = new List<string> { "https://example.com" },
|
||||
Caps = new capabilitiesBlock
|
||||
{
|
||||
Modes = new Dictionary<string, List<string>>
|
||||
@@ -110,7 +110,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
|
||||
definition = new IndexerDefinition // test search modes
|
||||
{
|
||||
Links = new List<string>{ "https://example.com" },
|
||||
Links = new List<string> { "https://example.com" },
|
||||
Caps = new capabilitiesBlock
|
||||
{
|
||||
Modes = new Dictionary<string, List<string>>
|
||||
|
@@ -27,7 +27,7 @@ namespace Jackett.Test.Common.Indexers
|
||||
yield return new TestCaseData("[1080p] Tokyo Revengers – 02").Returns("[1080p] Tokyo Revengers – E02");
|
||||
yield return new TestCaseData("[1080p] Mairimashita! Iruma-kun 2nd Season – 01").Returns("[1080p] Mairimashita! Iruma-kun – S2E01");
|
||||
yield return new TestCaseData("[540p] Seijo no Maryoku wa Bannou Desu – 02 v2 (Multi)").Returns("[540p] Seijo no Maryoku wa Bannou Desu – E02 v2 (Multi)");
|
||||
yield return new TestCaseData("[1080p] Yuukoku no Moriarty Part 2 – 01 (Multi)").Returns("[1080p] Yuukoku no Moriarty – S2E01 (Multi)");
|
||||
yield return new TestCaseData("[1080p] Yuukoku no Moriarty Part 2 – 01 (Multi)").Returns("[1080p] Yuukoku no Moriarty – S2E01 (Multi)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,8 +50,8 @@ namespace Jackett.Test.Common.Models
|
||||
{
|
||||
Link = link
|
||||
})
|
||||
{
|
||||
Releases = new List<ReleaseInfo>
|
||||
{
|
||||
Releases = new List<ReleaseInfo>
|
||||
{
|
||||
new ReleaseInfo // these fields are from websites and they can be problematic
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace Jackett.Test.Common.Models
|
||||
Origin = new TestIndexer()
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
var xml = resultPage.ToXml(link);
|
||||
|
||||
Assert.AreEqual(5, Regex.Matches(xml, validText).Count);
|
||||
|
@@ -196,7 +196,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // int category with subcategories (parent cat)
|
||||
{
|
||||
Categories = new [] { TorznabCatType.Movies.ID }
|
||||
Categories = new[] { TorznabCatType.Movies.ID }
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(2, trackerCats.Count);
|
||||
@@ -205,7 +205,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // string child category
|
||||
{
|
||||
Categories = new [] { TorznabCatType.MoviesSD.ID }
|
||||
Categories = new[] { TorznabCatType.MoviesSD.ID }
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(1, trackerCats.Count);
|
||||
@@ -217,7 +217,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // duplicate category (1 torznab cat => 2 indexer cats)
|
||||
{
|
||||
Categories = new [] { TorznabCatType.ConsoleXBox.ID }
|
||||
Categories = new[] { TorznabCatType.ConsoleXBox.ID }
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(2, trackerCats.Count);
|
||||
@@ -226,7 +226,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // custom cat "integer"
|
||||
{
|
||||
Categories = new [] { 100044 } // Console/Xbox_c
|
||||
Categories = new[] { 100044 } // Console/Xbox_c
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(1, trackerCats.Count);
|
||||
@@ -234,7 +234,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // custom cat "string"
|
||||
{
|
||||
Categories = new [] { 137107 } // Console/Wii_c
|
||||
Categories = new[] { 137107 } // Console/Wii_c
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(1, trackerCats.Count);
|
||||
@@ -242,14 +242,14 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
query = new TorznabQuery // unknown category
|
||||
{
|
||||
Categories = new [] { 9999 }
|
||||
Categories = new[] { 9999 }
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(0, trackerCats.Count);
|
||||
|
||||
query = new TorznabQuery // unknown custom cat
|
||||
{
|
||||
Categories = new [] { 100001 }
|
||||
Categories = new[] { 100001 }
|
||||
};
|
||||
trackerCats = tcc.MapTorznabCapsToTrackers(query);
|
||||
Assert.AreEqual(0, trackerCats.Count);
|
||||
@@ -270,7 +270,7 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(2030, torznabCats[0]);
|
||||
|
||||
// "integer" id with custom cats. 44 and 40 maps to ConsoleXbox but different custom cat
|
||||
torznabCats = tcc.MapTrackerCatToNewznab("44").ToList();
|
||||
torznabCats = tcc.MapTrackerCatToNewznab("44").ToList();
|
||||
Assert.AreEqual(2, torznabCats.Count);
|
||||
Assert.AreEqual(1040, torznabCats[0]);
|
||||
Assert.AreEqual(100044, torznabCats[1]);
|
||||
@@ -280,7 +280,7 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(100040, torznabCats[1]);
|
||||
|
||||
// "string" id with custom cats
|
||||
torznabCats = tcc.MapTrackerCatToNewznab("con_wii").ToList();
|
||||
torznabCats = tcc.MapTrackerCatToNewznab("con_wii").ToList();
|
||||
Assert.AreEqual(2, torznabCats.Count);
|
||||
Assert.AreEqual(1030, torznabCats[0]);
|
||||
Assert.AreEqual(137107, torznabCats[1]);
|
||||
@@ -330,25 +330,25 @@ namespace Jackett.Test.Common.Models
|
||||
{
|
||||
var tcc = CreateTestDataset();
|
||||
|
||||
Assert.AreEqual( new[] { TorznabCatType.Movies.ID }, // parent cat
|
||||
tcc.SupportedCategories(new []{ TorznabCatType.Movies.ID }));
|
||||
Assert.AreEqual( new[] { TorznabCatType.MoviesSD.ID }, // child cat
|
||||
tcc.SupportedCategories(new []{ TorznabCatType.MoviesSD.ID }));
|
||||
Assert.AreEqual( new[] { TorznabCatType.Movies.ID, TorznabCatType.MoviesSD.ID }, // parent & child cat
|
||||
tcc.SupportedCategories(new []{ TorznabCatType.Movies.ID, TorznabCatType.MoviesSD.ID }));
|
||||
Assert.AreEqual( new[] { 100040 }, // custom cat
|
||||
tcc.SupportedCategories(new []{ 100040 }));
|
||||
Assert.AreEqual( new[] { TorznabCatType.Movies.ID }, // mixed good and bad
|
||||
tcc.SupportedCategories(new []{ TorznabCatType.Movies.ID, 9999 }));
|
||||
Assert.AreEqual( new int[] {}, // not supported child cat
|
||||
tcc.SupportedCategories(new []{ TorznabCatType.Movies3D.ID }));
|
||||
Assert.AreEqual( new int[] {}, // unknown cat
|
||||
tcc.SupportedCategories(new []{ 9999 }));
|
||||
Assert.AreEqual( new int[] {}, // unknown custom cat
|
||||
tcc.SupportedCategories(new []{ 100001 }));
|
||||
Assert.AreEqual( new int[]{}, // empty list
|
||||
tcc.SupportedCategories(new int[]{}));
|
||||
Assert.AreEqual( new int[] {}, // null
|
||||
Assert.AreEqual(new[] { TorznabCatType.Movies.ID }, // parent cat
|
||||
tcc.SupportedCategories(new[] { TorznabCatType.Movies.ID }));
|
||||
Assert.AreEqual(new[] { TorznabCatType.MoviesSD.ID }, // child cat
|
||||
tcc.SupportedCategories(new[] { TorznabCatType.MoviesSD.ID }));
|
||||
Assert.AreEqual(new[] { TorznabCatType.Movies.ID, TorznabCatType.MoviesSD.ID }, // parent & child cat
|
||||
tcc.SupportedCategories(new[] { TorznabCatType.Movies.ID, TorznabCatType.MoviesSD.ID }));
|
||||
Assert.AreEqual(new[] { 100040 }, // custom cat
|
||||
tcc.SupportedCategories(new[] { 100040 }));
|
||||
Assert.AreEqual(new[] { TorznabCatType.Movies.ID }, // mixed good and bad
|
||||
tcc.SupportedCategories(new[] { TorznabCatType.Movies.ID, 9999 }));
|
||||
Assert.AreEqual(new int[] { }, // not supported child cat
|
||||
tcc.SupportedCategories(new[] { TorznabCatType.Movies3D.ID }));
|
||||
Assert.AreEqual(new int[] { }, // unknown cat
|
||||
tcc.SupportedCategories(new[] { 9999 }));
|
||||
Assert.AreEqual(new int[] { }, // unknown custom cat
|
||||
tcc.SupportedCategories(new[] { 100001 }));
|
||||
Assert.AreEqual(new int[] { }, // empty list
|
||||
tcc.SupportedCategories(new int[] { }));
|
||||
Assert.AreEqual(new int[] { }, // null
|
||||
tcc.SupportedCategories(null));
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"bad", new List<string> {"q"}} // bad search mode
|
||||
@@ -100,7 +101,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string> {"bad"}} // search mode with bad parameters
|
||||
@@ -141,7 +143,8 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(new List<TvSearchParam> { TvSearchParam.Q, TvSearchParam.TvdbId }, torznabCaps.TvSearchParams);
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -155,7 +158,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -197,7 +201,8 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(new List<MovieSearchParam> { MovieSearchParam.Q, MovieSearchParam.ImdbId }, torznabCaps.MovieSearchParams);
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -211,7 +216,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -253,7 +259,8 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(new List<MusicSearchParam> { MusicSearchParam.Q, MusicSearchParam.Label }, torznabCaps.MusicSearchParams);
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -267,7 +274,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -309,7 +317,8 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(new List<BookSearchParam> { BookSearchParam.Q, BookSearchParam.Title }, torznabCaps.BookSearchParams);
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -323,7 +332,8 @@ namespace Jackett.Test.Common.Models
|
||||
}
|
||||
|
||||
torznabCaps = new TorznabCapabilities();
|
||||
try {
|
||||
try
|
||||
{
|
||||
torznabCaps.ParseCardigannSearchModes(new Dictionary<string, List<string>>
|
||||
{
|
||||
{"search", new List<string>{"q"}},
|
||||
@@ -406,7 +416,7 @@ namespace Jackett.Test.Common.Models
|
||||
|
||||
// test categories
|
||||
torznabCaps = new TorznabCapabilities(); // child category
|
||||
torznabCaps.Categories.AddCategoryMapping("c1", TorznabCatType.MoviesSD);
|
||||
torznabCaps.Categories.AddCategoryMapping("c1", TorznabCatType.MoviesSD);
|
||||
xDocument = torznabCaps.GetXDocument();
|
||||
var xDocumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList();
|
||||
Assert.AreEqual(1, xDocumentCategories?.Count);
|
||||
@@ -418,7 +428,7 @@ namespace Jackett.Test.Common.Models
|
||||
Assert.AreEqual(TorznabCatType.MoviesSD.Name, xDocumentSubCategories?[0].Attribute("name")?.Value);
|
||||
|
||||
torznabCaps = new TorznabCapabilities(); // parent (with description generates a custom cat) and child category
|
||||
torznabCaps.Categories.AddCategoryMapping("1", TorznabCatType.Movies, "Classic Movies");
|
||||
torznabCaps.Categories.AddCategoryMapping("1", TorznabCatType.Movies, "Classic Movies");
|
||||
torznabCaps.Categories.AddCategoryMapping("c2", TorznabCatType.MoviesSD);
|
||||
xDocument = torznabCaps.GetXDocument();
|
||||
xDocumentCategories = xDocument.Root?.Element("categories")?.Elements("category").ToList();
|
||||
@@ -474,20 +484,20 @@ namespace Jackett.Test.Common.Models
|
||||
torznabCaps1 = new TorznabCapabilities
|
||||
{
|
||||
SearchAvailable = false,
|
||||
TvSearchParams = new List<TvSearchParam> {TvSearchParam.Q},
|
||||
MovieSearchParams = new List<MovieSearchParam> {MovieSearchParam.Q},
|
||||
MusicSearchParams = new List<MusicSearchParam> {MusicSearchParam.Q},
|
||||
BookSearchParams = new List<BookSearchParam> {BookSearchParam.Q}
|
||||
TvSearchParams = new List<TvSearchParam> { TvSearchParam.Q },
|
||||
MovieSearchParams = new List<MovieSearchParam> { MovieSearchParam.Q },
|
||||
MusicSearchParams = new List<MusicSearchParam> { MusicSearchParam.Q },
|
||||
BookSearchParams = new List<BookSearchParam> { BookSearchParam.Q }
|
||||
};
|
||||
torznabCaps1.Categories.AddCategoryMapping("1", TorznabCatType.Movies);
|
||||
torznabCaps1.Categories.AddCategoryMapping("c1", new TorznabCategory(100001, "CustomCat1"));
|
||||
torznabCaps2 = new TorznabCapabilities
|
||||
{
|
||||
SearchAvailable = false,
|
||||
TvSearchParams = new List<TvSearchParam> {TvSearchParam.Season},
|
||||
MovieSearchParams = new List<MovieSearchParam> {MovieSearchParam.ImdbId},
|
||||
MusicSearchParams = new List<MusicSearchParam> {MusicSearchParam.Artist},
|
||||
BookSearchParams = new List<BookSearchParam> {BookSearchParam.Title}
|
||||
TvSearchParams = new List<TvSearchParam> { TvSearchParam.Season },
|
||||
MovieSearchParams = new List<MovieSearchParam> { MovieSearchParam.ImdbId },
|
||||
MusicSearchParams = new List<MusicSearchParam> { MusicSearchParam.Artist },
|
||||
BookSearchParams = new List<BookSearchParam> { BookSearchParam.Title }
|
||||
};
|
||||
torznabCaps2.Categories.AddCategoryMapping("2", TorznabCatType.TVAnime);
|
||||
torznabCaps2.Categories.AddCategoryMapping("c2", new TorznabCategory(100002, "CustomCat2"));
|
||||
|
@@ -44,7 +44,7 @@ namespace Jackett.Test.Common.Utils
|
||||
{
|
||||
// malformed cookies
|
||||
var cookieHeader = "__cfduidd6237f041586694295; __cf_;bm TlOng; good_cookie=value";
|
||||
var expectedCookieDictionary = new Dictionary<string, string> {{"good_cookie", "value"},};
|
||||
var expectedCookieDictionary = new Dictionary<string, string> { { "good_cookie", "value" }, };
|
||||
CollectionAssert.AreEqual(expectedCookieDictionary, CookieUtil.CookieHeaderToDictionary(cookieHeader));
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Jackett.Test.Common.Utils
|
||||
{"__cf_=bm", "34234234"}
|
||||
};
|
||||
var ex = Assert.Throws<FormatException>(() => CookieUtil.CookieDictionaryToHeader(cookieDictionary));
|
||||
Assert.AreEqual( "The cookie '__cf_=bm=34234234' is malformed.", ex.Message);
|
||||
Assert.AreEqual("The cookie '__cf_=bm=34234234' is malformed.", ex.Message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -90,7 +90,7 @@ namespace Jackett.Test.Common.Utils
|
||||
{"__cf_bm", "34234 234"}
|
||||
};
|
||||
var ex = Assert.Throws<FormatException>(() => CookieUtil.CookieDictionaryToHeader(cookieDictionary));
|
||||
Assert.AreEqual( "The cookie '__cf_bm=34234 234' is malformed.", ex.Message);
|
||||
Assert.AreEqual("The cookie '__cf_bm=34234 234' is malformed.", ex.Message);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -63,11 +63,11 @@ namespace Jackett.Test.Common.Utils
|
||||
// there are few tests because we are using a well known library
|
||||
var now = DateTime.Now;
|
||||
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 4, 20, 19, new TimeSpan(-4, -30, 0)).DateTime,
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 4, 20, 19, new TimeSpan(-4, -30, 0)).DateTime,
|
||||
DateTimeUtil.FromFuzzyTime("21 Jun 2010 04:20:19 -0430 blah"));
|
||||
Assert.AreEqual(new DateTime(2005, 6, 10, 10, 30, 0),
|
||||
Assert.AreEqual(new DateTime(2005, 6, 10, 10, 30, 0),
|
||||
DateTimeUtil.FromFuzzyTime("June 10, 2005 10:30AM", "UK"));
|
||||
Assert.AreEqual(new DateTime(now.Year, now.Month, now.Day, 19, 54, 0),
|
||||
Assert.AreEqual(new DateTime(now.Year, now.Month, now.Day, 19, 54, 0),
|
||||
DateTimeUtil.FromFuzzyTime("today 19:54"));
|
||||
Assert.True((now - DateTimeUtil.FromFuzzyTime("Yesterday at 10:20 pm")).TotalSeconds <= 3600 * 24); // 1 day
|
||||
Assert.True((now - DateTimeUtil.FromFuzzyTime("Sunday at 14:30")).TotalSeconds <= 3600 * 24 * 7); // 1 week
|
||||
@@ -118,7 +118,7 @@ namespace Jackett.Test.Common.Utils
|
||||
Assert.True((now - DateTimeUtil.FromUnknown("Saturday at 00:20", relativeFrom: now)).TotalSeconds <= 3600 * 24 * 7);
|
||||
Assert.True((now - DateTimeUtil.FromUnknown("sunday at 22:00", relativeFrom: now)).TotalSeconds <= 3600 * 24 * 7);
|
||||
|
||||
Assert.AreEqual(new DateTime(2020, 10, 31, 3, 8, 27, DateTimeKind.Utc).ToLocalTime(),
|
||||
Assert.AreEqual(new DateTime(2020, 10, 31, 3, 8, 27, DateTimeKind.Utc).ToLocalTime(),
|
||||
DateTimeUtil.FromUnknown("1604113707", relativeFrom: now));
|
||||
|
||||
var refDate = new DateTime(2021, 03, 12, 12, 00, 00, DateTimeKind.Local);
|
||||
@@ -153,13 +153,13 @@ namespace Jackett.Test.Common.Utils
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 4, 20, 19, new TimeSpan(-4, 0, 0)).ToLocalTime().DateTime,
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 4, 20, 19, new TimeSpan(-4, 0, 0)).ToLocalTime().DateTime,
|
||||
DateTimeUtil.ParseDateTimeGoLang("21-06-2010 04:20:19 -04:00", "02-01-2006 15:04:05 -07:00"));
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 0, 0, 0, new TimeSpan(-5, -30, 0)).ToLocalTime().DateTime,
|
||||
Assert.AreEqual(new DateTimeOffset(2010, 6, 21, 0, 0, 0, new TimeSpan(-5, -30, 0)).ToLocalTime().DateTime,
|
||||
DateTimeUtil.ParseDateTimeGoLang("2010-06-21 -05:30", "2006-01-02 -07:00"));
|
||||
var refDate = new DateTime(2021, 03, 12, 12, 00, 00, DateTimeKind.Local);
|
||||
Assert.AreEqual(new DateTime(refDate.Year - 1, 9, 14, 7, 0, 0),
|
||||
DateTimeUtil.ParseDateTimeGoLang("7am Sep. 14", "3pm Jan. 2", relativeFrom:refDate));
|
||||
Assert.AreEqual(new DateTime(refDate.Year - 1, 9, 14, 7, 0, 0),
|
||||
DateTimeUtil.ParseDateTimeGoLang("7am Sep. 14", "3pm Jan. 2", relativeFrom: refDate));
|
||||
|
||||
// bad cases
|
||||
try
|
||||
|
@@ -13,7 +13,7 @@ namespace Jackett.Test.Common.Utils
|
||||
[Test]
|
||||
public void GetQueryStringTests()
|
||||
{
|
||||
#region Encoding Tests
|
||||
#region Encoding Tests
|
||||
|
||||
//Add windows-1251 to Encoding list if not present
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
@@ -41,9 +41,9 @@ namespace Jackett.Test.Common.Utils
|
||||
//Encoding should make values websafe, but not keys
|
||||
StringAssert.Contains("space key=space+value", encodingNvc.GetQueryString());
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Separator Tests
|
||||
#region Separator Tests
|
||||
|
||||
var separatorNvc = new NameValueCollection
|
||||
{
|
||||
@@ -62,9 +62,9 @@ namespace Jackett.Test.Common.Utils
|
||||
Assert.AreEqual(noSeparator, separatorNvc.GetQueryString(separator: null));
|
||||
Assert.AreEqual(noSeparator, separatorNvc.GetQueryString(separator: string.Empty));
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Split Keys Tests
|
||||
#region Split Keys Tests
|
||||
|
||||
var duplicateKeysNvc = new NameValueCollection
|
||||
{
|
||||
@@ -84,9 +84,9 @@ namespace Jackett.Test.Common.Utils
|
||||
Assert.AreEqual(
|
||||
"key1=value&key1=duplicate&key2=value2", duplicateKeysNvc.GetQueryString(duplicateKeysIfMulti: true));
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Edge Case Tests
|
||||
#region Edge Case Tests
|
||||
|
||||
//Throws NullReferenceException if the NameValueCollection is null in all cases
|
||||
Assert.Throws<NullReferenceException>(() => ((NameValueCollection)null).GetQueryString());
|
||||
@@ -94,7 +94,7 @@ namespace Jackett.Test.Common.Utils
|
||||
//Returns empty string on empty collection in all cases
|
||||
Assert.AreEqual(string.Empty, new NameValueCollection().GetQueryString());
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@@ -9,9 +9,9 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Jackett.Test.TestHelpers
|
||||
{
|
||||
public class TestWebIndexer: BaseWebIndexer
|
||||
public class TestWebIndexer : BaseWebIndexer
|
||||
{
|
||||
public TestWebIndexer():
|
||||
public TestWebIndexer() :
|
||||
base(id: "test_id",
|
||||
name: "test_name",
|
||||
description: "test_description",
|
||||
@@ -26,7 +26,7 @@ namespace Jackett.Test.TestHelpers
|
||||
{
|
||||
Encoding = Encoding.UTF8;
|
||||
Language = "en-us";
|
||||
Type = "private";
|
||||
Type = "private";
|
||||
}
|
||||
|
||||
public override string[] AlternativeSiteLinks { get; protected set; } = {
|
||||
|
Reference in New Issue
Block a user