using Data.SeaHavenIndustries; using FluentAssertions; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using SeaHaven.DataServices.DependencyInjection; using SeaHaven.DataServices.Implementation; using SeaHaven.DataServices.Interfaces; using SeaHaven.Services.DependencyInjection; using SeaHaven.Services.Implementation; using SeaHaven.Services.Interfaces; using Xunit; namespace Api.SeaHavenIndustries.Tests; public class ServiceRegistrationTests { private static ServiceProvider BuildProvider() { var services = new ServiceCollection(); services.AddLogging(); services.AddDbContext(options => options.UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())); services.AddIdentity() .AddEntityFrameworkStores(); services.AddDataServices(); services.AddBusinessServices(); return services.BuildServiceProvider(); } [Fact] public void ConventionDi_RegistersAllFiveFeatureServices() { using var provider = BuildProvider(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); } [Fact] public void ConventionDi_RegistersFeatureDataServices() { using var provider = BuildProvider(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); } [Fact] public void ConventionDi_RegistersFollowUpLocationDispatchSettingsServices() { using var provider = BuildProvider(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); } [Fact] public void ConventionDi_RegistersFollowUpLocationDispatchSettingsDataServices() { using var provider = BuildProvider(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); provider.GetRequiredService().Should().BeOfType(); } }