Commit 8413066e authored by Scott DePouw's avatar Scott DePouw

Add NoOpDomainEventDispatcher for integration test purposes.

parent d2a1cce0
......@@ -72,15 +72,6 @@ namespace CleanArchitecture.Web
return container.GetInstance<IServiceProvider>();
}
public void ConfigureTesting(IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
this.Configure(app, env, loggerFactory);
SeedData.PopulateTestData(app.ApplicationServices.GetService<AppDbContext>());
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
......
using CleanArchitecture.Infrastructure.Data;
using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Infrastructure.Data;
using CleanArchitecture.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
......@@ -28,11 +29,13 @@ namespace CleanArchitecture.Tests.Integration.Web
options.UseInternalServiceProvider(serviceProvider);
});
services.AddScoped<IDomainEventDispatcher, NoOpDomainEventDispatcher>();
// Build the service provider.
var sp = services.BuildServiceProvider();
// Create a scope to obtain a reference to the database
// context (ApplicationDbContext).
// context (AppDbContext).
using (var scope = sp.CreateScope())
{
var scopedServices = scope.ServiceProvider;
......@@ -51,7 +54,7 @@ namespace CleanArchitecture.Tests.Integration.Web
}
catch (Exception ex)
{
logger.LogError(ex, $"An error occurred seeding the " +
logger.LogError(ex, "An error occurred seeding the " +
"database with test messages. Error: {ex.Message}");
}
}
......
using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Core.SharedKernel;
namespace CleanArchitecture.Tests.Integration.Web
{
public class NoOpDomainEventDispatcher : IDomainEventDispatcher
{
public void Dispatch(BaseDomainEvent domainEvent) { }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment