Validate scopes of service injections in tests

This commit is contained in:
Nicolas Dorier
2025-11-14 23:44:03 +09:00
parent 62552a7bfe
commit 749c772218
11 changed files with 50 additions and 66 deletions

View File

@@ -18,6 +18,7 @@ using BTCPayServer.Services.Rates;
using Dapper;
using Microsoft.AspNetCore.Routing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static BTCPayServer.Data.Subscriptions.SubscriberData;
@@ -30,7 +31,7 @@ public class SubscriptionHostedService(
EventAggregator eventAggregator,
ApplicationDbContextFactory applicationDbContextFactory,
SettingsRepository settingsRepository,
UIInvoiceController invoiceController,
IServiceScopeFactory scopeFactory,
CurrencyNameTable currencyNameTable,
LinkGenerator linkGenerator,
Logs logger) : EventHostedServiceBase(eventAggregator, logger), IPeriodicTask
@@ -162,6 +163,8 @@ public class SubscriptionHostedService(
if (amount > 0)
{
using var scope = scopeFactory.CreateScope();
var invoiceController = scope.ServiceProvider.GetRequiredService<UIInvoiceController>();
var request = await invoiceController.CreateInvoiceCoreRaw(new()
{
Currency = plan.Currency,