mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
#31 (upstream) Add http context handling to tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Moq.Protected;
|
using Moq.Protected;
|
||||||
using octo_fiesta.Models.Settings;
|
using octo_fiesta.Models.Settings;
|
||||||
@@ -18,16 +19,22 @@ public class SubsonicProxyServiceTests
|
|||||||
{
|
{
|
||||||
_mockHttpMessageHandler = new Mock<HttpMessageHandler>();
|
_mockHttpMessageHandler = new Mock<HttpMessageHandler>();
|
||||||
var httpClient = new HttpClient(_mockHttpMessageHandler.Object);
|
var httpClient = new HttpClient(_mockHttpMessageHandler.Object);
|
||||||
|
|
||||||
_mockHttpClientFactory = new Mock<IHttpClientFactory>();
|
_mockHttpClientFactory = new Mock<IHttpClientFactory>();
|
||||||
_mockHttpClientFactory.Setup(x => x.CreateClient(It.IsAny<string>())).Returns(httpClient);
|
_mockHttpClientFactory.Setup(x => x.CreateClient(It.IsAny<string>())).Returns(httpClient);
|
||||||
|
|
||||||
var settings = Options.Create(new SubsonicSettings
|
var settings = Options.Create(new SubsonicSettings
|
||||||
{
|
{
|
||||||
Url = "http://localhost:4533"
|
Url = "http://localhost:4533"
|
||||||
});
|
});
|
||||||
|
|
||||||
_service = new SubsonicProxyService(_mockHttpClientFactory.Object, settings);
|
var httpContext = new DefaultHttpContext();
|
||||||
|
var httpContextAccessor = new HttpContextAccessor
|
||||||
|
{
|
||||||
|
HttpContext = httpContext
|
||||||
|
};
|
||||||
|
|
||||||
|
_service = new SubsonicProxyService(_mockHttpClientFactory.Object, settings, httpContextAccessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in New Issue
Block a user