using Microsoft.Extensions.DependencyInjection; using NSubstitute; using RackPeek.Domain.Resources; using RackPeek.Domain.Resources.Hardware; using RackPeek.Domain.Resources.Services; using RackPeek.Domain.Resources.SystemResources; namespace Tests.HardwareResources; public class UsecaseTestHost { private readonly ServiceCollection _sc; public UsecaseTestHost() { HardwareRepo = Substitute.For(); SystemRepo = Substitute.For(); ServiceRepo = Substitute.For(); ResourceRepo = Substitute.For(); _sc = new ServiceCollection(); _sc.AddSingleton(HardwareRepo); _sc.AddSingleton(SystemRepo); _sc.AddSingleton(ServiceRepo); _sc.AddSingleton(ResourceRepo); } public IHardwareRepository HardwareRepo { get; set; } public ISystemRepository SystemRepo { get; set; } public IServiceRepository ServiceRepo { get; set; } public IResourceRepository ResourceRepo { get; set; } public T Get() where T : notnull { _sc.AddSingleton(typeof(T)); var sp = _sc.BuildServiceProvider(); return sp.GetRequiredService(); } }