using AvParser.Core.Settings;
using ReactiveUI.Primitives.Signals;
namespace AvParser.UI.Tests.Fakes;
/// In-memory settings, so tests never touch the developer's real profile.
internal sealed class FakeSettingsService(AppSettings? initial = null) : ISettingsService, IDisposable
{
private readonly BehaviorSignal _current = new(initial ?? new AppSettings());
public AppSettings Current => _current.Value;
public IObservable Changes => _current;
/// How many times was called.
public int FlushCount { get; private set; }
/// Every value the settings have taken, oldest first.
public List History { get; } = [];
public void Update(Func mutate)
{
var next = mutate(_current.Value);
History.Add(next);
_current.OnNext(next);
}
public Task FlushAsync(CancellationToken cancellationToken = default)
{
FlushCount++;
return Task.CompletedTask;
}
public void Dispose() => _current.Dispose();
}