Added Chobit integration. Updated tests.
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
using JSMR.Application.Integrations.DLSite.Models;
|
||||
using JSMR.Domain.Enums;
|
||||
using JSMR.Domain.ValueObjects;
|
||||
using JSMR.Infrastructure.Http;
|
||||
using JSMR.Infrastructure.Integrations.DLSite;
|
||||
using JSMR.Infrastructure.Integrations.DLSite.Mapping;
|
||||
using JSMR.Infrastructure.Integrations.DLSite.Models;
|
||||
using JSMR.Tests.Extensions;
|
||||
using JSMR.Tests.Http;
|
||||
using JSMR.Tests.Utilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Shouldly;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace JSMR.Tests.Integrations.DLSite;
|
||||
|
||||
@@ -20,17 +21,33 @@ public class DLSiteClientTests
|
||||
return await ResourceHelper.ReadAsync($"JSMR.Tests.Integrations.DLSite.{resourceName}");
|
||||
}
|
||||
|
||||
private static async Task<DLSiteClient> GetDLSiteClientThatReturns(string resourceName)
|
||||
{
|
||||
string content = await ReadJsonResourceAsync(resourceName);
|
||||
|
||||
FakeHttpMessageHandler handler = new(request =>
|
||||
{
|
||||
return new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent(content, Encoding.UTF8, "application/json")
|
||||
};
|
||||
});
|
||||
|
||||
HttpClient httpClient = new(handler)
|
||||
{
|
||||
BaseAddress = new Uri("https://www.fake-dlsite.com/")
|
||||
};
|
||||
|
||||
var logger = Substitute.For<ILogger<DLSiteClient>>();
|
||||
var client = new DLSiteClient(httpClient, logger);
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Deserialize_Product_Info_Collection()
|
||||
{
|
||||
string productInfoJson = await ReadJsonResourceAsync("Product-Info.json");
|
||||
|
||||
IHttpService httpService = Substitute.For<IHttpService>();
|
||||
httpService.ReturnsContent(productInfoJson);
|
||||
|
||||
var logger = Substitute.For<ILogger<DLSiteClient>>();
|
||||
var client = new DLSiteClient(httpService, logger);
|
||||
|
||||
var client = await GetDLSiteClientThatReturns("Product-Info.json");
|
||||
var result = await client.GetVoiceWorkDetailsAsync(["RJ01230163", "RJ01536422"], CancellationToken.None);
|
||||
|
||||
result.Count.ShouldBe(2);
|
||||
|
||||
Reference in New Issue
Block a user