using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using ZB.MOM.WW.LmxOpcUa.Host.Domain; namespace ZB.MOM.WW.LmxOpcUa.Tests.Helpers { public class FakeGalaxyRepository : IGalaxyRepository { public event Action? OnGalaxyChanged; public List Hierarchy { get; set; } = new List(); public List Attributes { get; set; } = new List(); public DateTime? LastDeployTime { get; set; } = DateTime.UtcNow; public bool ConnectionSucceeds { get; set; } = true; public bool ShouldThrow { get; set; } public Task> GetHierarchyAsync(CancellationToken ct = default) { if (ShouldThrow) throw new Exception("Simulated DB failure"); return Task.FromResult(Hierarchy); } public Task> GetAttributesAsync(CancellationToken ct = default) { if (ShouldThrow) throw new Exception("Simulated DB failure"); return Task.FromResult(Attributes); } public Task GetLastDeployTimeAsync(CancellationToken ct = default) { if (ShouldThrow) throw new Exception("Simulated DB failure"); return Task.FromResult(LastDeployTime); } public Task TestConnectionAsync(CancellationToken ct = default) { if (ShouldThrow) throw new Exception("Simulated DB failure"); return Task.FromResult(ConnectionSucceeds); } public void RaiseGalaxyChanged() => OnGalaxyChanged?.Invoke(); } }