#31 (upstream) Add http context handling to tests

This commit is contained in:
bransoned
2026-01-11 19:03:21 -05:00
parent 7ed4212b53
commit bdac8ac132

View File

@@ -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;
@@ -22,12 +23,18 @@ public class SubsonicProxyServiceTests
_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]