mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-27 22:56:45 -04:00
New: Multi target net framework 4.6.2 and net core 3.0
This commit is contained in:
@@ -3,11 +3,12 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Common.Http;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
@@ -22,7 +23,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
public class FingerPrintTest
|
||||
{
|
||||
public string RequestContent { get; set; }
|
||||
public string Request { get; set; }
|
||||
public string Response { get; set; }
|
||||
}
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
public void UseAcoustidResponses()
|
||||
{
|
||||
// responses were generated by editing HttpClient to write out the content bytes as a string
|
||||
// using BitConverter.ToString(request.ContentData)
|
||||
// using System.Text.Encoding.UTF8.GetString(request.ContentData.Decompress());
|
||||
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "Files", "Fingerprinting", "AcoustidResponses.json");
|
||||
var responses = JsonConvert.DeserializeObject<List<FingerPrintTest>>(File.ReadAllText(path));
|
||||
|
||||
@@ -38,16 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
Mocker.GetMock<IHttpClient>()
|
||||
.Setup(o => o.Post<LookupResponse>(
|
||||
It.Is<HttpRequest>(v =>
|
||||
v.Url.Equals(new HttpUri("https://api.acoustid.org/v2/lookup")) &&
|
||||
v.Headers.Contains(new KeyValuePair<string, string>("Content-Encoding", "gzip")) &&
|
||||
v.Headers.ContentType == "application/x-www-form-urlencoded" &&
|
||||
// Skip past the first bit of gzip header which varies by OS:
|
||||
// http://www.onicos.com/staff/iz/formats/gzip.html
|
||||
BitConverter.ToString(v.ContentData).Substring(31) == response.RequestContent.Substring(31)
|
||||
)))
|
||||
It.Is<HttpRequest>(v =>
|
||||
v.Url.Equals(new HttpUri("https://api.acoustid.org/v2/lookup")) &&
|
||||
v.Headers.Contains(new KeyValuePair<string, string>("Content-Encoding", "gzip")) &&
|
||||
v.Headers.ContentType == "application/x-www-form-urlencoded" &&
|
||||
Encoding.UTF8.GetString(v.ContentData.Decompress()) == response.Request
|
||||
)))
|
||||
.Returns<HttpRequest>(r => new HttpResponse<LookupResponse>(new HttpResponse(r, new HttpHeader(), response.Response)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user