Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Brereton authored and Tom Brereton committed Sep 10, 2024
1 parent e9e84f3 commit 1bd8451
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Web.Api/Features/Calendars/CreateCalendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class CreateCalendar
{
public class Handler : INotificationHandler<UserAccountCreatedDomainEvent>
{
private IUserAccountRepository _repository;
private readonly IUserAccountRepository _repository;

public Handler(IUserAccountRepository repository)
{
Expand Down
16 changes: 16 additions & 0 deletions src/Web.Api/Features/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Carter;
using FluentValidation;

namespace Web.Api.Features;

public static class DependencyInjection
{
public static IServiceCollection AddFeatures(this IServiceCollection services)
{
var assembly = typeof(Web.Api.Program).Assembly;
services.AddMediatR(config => config.RegisterServicesFromAssembly(assembly));
services.AddCarter();
services.AddValidatorsFromAssembly(assembly);
return services;
}
}
8 changes: 2 additions & 6 deletions src/Web.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using Carter;
using FluentValidation;
using Web.Api.Features;
using Web.Api.Infrastructure;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddFeatures();
builder.Services.AddInfrastructure(builder.Configuration);

var assembly = typeof(Web.Api.Program).Assembly;
builder.Services.AddMediatR(config => config.RegisterServicesFromAssembly(assembly));
builder.Services.AddCarter();
builder.Services.AddValidatorsFromAssembly(assembly);

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Testcontainers.MsSql;
using Web.Api.Features;
using Web.Api.Infrastructure;
using Web.Api.Infrastructure.Database;

Expand All @@ -24,6 +25,7 @@ public async Task InitializeAsync()

Services = new ServiceCollection()
.AddInfrastructure(config)
.AddFeatures()
.BuildServiceProvider();

var db = Services.GetRequiredService<AppointerDbContext>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Web.Api.IntegrationTests.Infrastructure.Database;

public class AppointerDbContextShould : MsSqlContainerStartup
{
// [Fact]
[Fact]
public async Task PersistUserAccount()
{
// arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Web.Api.IntegrationTests.Infrastructure.Publishing;

public class AppointerDbContextShould : MsSqlContainerStartup
{
// [Fact]
[Fact]
public async Task PersistUserAccount()
{
// arrange
Expand Down

0 comments on commit 1bd8451

Please sign in to comment.