using System; using Microsoft.Extensions.Options; using Moq; namespace slskd.Tests.Unit { public class TestOptionsMonitor : IOptionsMonitor { private Action _listener; public TestOptionsMonitor(TOptions currentValue) { CurrentValue = currentValue; } public TOptions CurrentValue { get; private set; } public TOptions Get(string name) { return CurrentValue; } public void Set(TOptions value) { CurrentValue = value; _listener.Invoke(value, null); } public IDisposable OnChange(Action listener) { _listener = listener; return new Mock().Object; } public void RaiseOnChange(TOptions options) { _listener(options, null); } } }