- StorageServiceTests: replace out-param + manual dispose with IAsyncLifetime - PictureServiceTests: Assert.True bound checks -> Assert.InRange - CreateAlbumCommandHandlerTests: assert the specific NotFound error type instead of just IsError, matching what the test name promises - CreateAlbumRequestValidatorTests: replace a boundary Theory that computed its expected result inline with explicit Facts against the real AlbumReleaseYear constants - Remove unused using directives across a handful of production and test files found during the review Full suite verified green: 250/250 tests passing, 0 build warnings.
31 lines
1.3 KiB
C#
31 lines
1.3 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using Musify.Application.Contracts;
|
|
using Musify.Infrastructure.Configuration;
|
|
|
|
namespace Musify.Infrastructure.Persistence
|
|
{
|
|
public static class DatabaseDependencyInjection
|
|
{
|
|
public static IServiceCollection AddDatabase(this IServiceCollection serviceDescriptors, IConfiguration configuration)
|
|
{
|
|
serviceDescriptors
|
|
.AddOptionsWithValidateOnStart<DatabaseConfiguration>()
|
|
.Bind(configuration.GetRequiredSection(DatabaseConfiguration.SectionName))
|
|
.ValidateDataAnnotations();
|
|
|
|
serviceDescriptors.AddSingleton(serviceProvider =>
|
|
serviceProvider.GetRequiredService<IOptions<DatabaseConfiguration>>().Value);
|
|
|
|
serviceDescriptors.AddSingleton<AuditableEntityInterceptor>();
|
|
|
|
serviceDescriptors.AddDbContext<Database>((serviceProvider, options) =>
|
|
options.AddInterceptors(serviceProvider.GetRequiredService<AuditableEntityInterceptor>()));
|
|
|
|
serviceDescriptors.AddScoped<IDatabase>(serviceProvider => serviceProvider.GetRequiredService<Database>());
|
|
|
|
return serviceDescriptors;
|
|
}
|
|
}
|
|
} |