Created TestOptionsMonitor.cs and updated tests to use this new class
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Configuration.UmbracoSettings;
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Umbraco.Cms.Core.Events
|
||||
INotificationService notificationService,
|
||||
IUserService userService,
|
||||
ILocalizedTextService textService,
|
||||
IOptions<GlobalSettings> globalSettings,
|
||||
IOptionsMonitor<GlobalSettings> globalSettings,
|
||||
ILogger<Notifier> logger)
|
||||
{
|
||||
_backOfficeSecurityAccessor = backOfficeSecurityAccessor;
|
||||
@@ -144,7 +144,7 @@ namespace Umbraco.Cms.Core.Events
|
||||
_notificationService = notificationService;
|
||||
_userService = userService;
|
||||
_textService = textService;
|
||||
_globalSettings = globalSettings.Value;
|
||||
_globalSettings = globalSettings.CurrentValue;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
|
||||
16
src/Umbraco.Tests.Common/TestOptionsMonitor.cs
Normal file
16
src/Umbraco.Tests.Common/TestOptionsMonitor.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Common
|
||||
{
|
||||
public class TestOptionsMonitor<T> : IOptionsMonitor<T> where T : class
|
||||
{
|
||||
public TestOptionsMonitor(T currentValue) => CurrentValue = currentValue;
|
||||
|
||||
public T Get(string name) => CurrentValue;
|
||||
|
||||
public IDisposable OnChange(Action<T, string> listener) => null;
|
||||
|
||||
public T CurrentValue { get; }
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ using Umbraco.Cms.Core.Runtime;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.HostedServices;
|
||||
using Umbraco.Cms.Tests.Common;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.HostedServices
|
||||
{
|
||||
@@ -107,7 +108,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.HostedServices
|
||||
return new KeepAlive(
|
||||
mockHostingEnvironment.Object,
|
||||
mockMainDom.Object,
|
||||
Options.Create(settings),
|
||||
|
||||
new TestOptionsMonitor<KeepAliveSettings>(settings),
|
||||
mockLogger.Object,
|
||||
mockProfilingLogger.Object,
|
||||
mockServerRegistrar.Object,
|
||||
|
||||
@@ -16,6 +16,7 @@ using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.HostedServices;
|
||||
using Umbraco.Cms.Tests.Common;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.HostedServices
|
||||
{
|
||||
@@ -87,7 +88,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.HostedServices
|
||||
mockMainDom.Object,
|
||||
mockServerRegistrar.Object,
|
||||
_mockAuditService.Object,
|
||||
Options.Create(settings),
|
||||
new TestOptionsMonitor<LoggingSettings>(settings),
|
||||
mockScopeProvider.Object,
|
||||
mockLogger.Object,
|
||||
mockProfilingLogger.Object);
|
||||
|
||||
Reference in New Issue
Block a user