using JdeScoping.Core.Interfaces; namespace JdeScoping.Infrastructure.Tests.Helpers; /// /// In-memory implementation of ISecureStoreService for unit testing. /// public class InMemorySecureStore : ISecureStoreService { private readonly Dictionary _secrets = new(); private bool _disposed; public string? Get(string key) { ObjectDisposedException.ThrowIf(_disposed, this); return _secrets.TryGetValue(key, out var value) ? value : null; } public string GetRequired(string key) { ObjectDisposedException.ThrowIf(_disposed, this); if (!_secrets.TryGetValue(key, out var value)) throw new KeyNotFoundException($"Secret '{key}' not found."); return value; } public void Set(string key, string value) { ObjectDisposedException.ThrowIf(_disposed, this); _secrets[key] = value; } public bool Contains(string key) { ObjectDisposedException.ThrowIf(_disposed, this); return _secrets.ContainsKey(key); } public bool Remove(string key) { ObjectDisposedException.ThrowIf(_disposed, this); return _secrets.Remove(key); } public void Save() { ObjectDisposedException.ThrowIf(_disposed, this); // No-op for in-memory store } public IEnumerable Keys => _secrets.Keys.ToList().AsReadOnly(); public void Dispose() { _disposed = true; GC.SuppressFinalize(this); } }