1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.DependencyInjection;
- using Castle.MicroKernel.Registration;
- using Castle.Windsor.MsDependencyInjection;
- using Abp.Dependency;
- using YGNT.Exam.EntityFrameworkCore;
- using YGNT.Exam.Identity;
- namespace YGNT.Exam.Tests.DependencyInjection
- {
- public static class ServiceCollectionRegistrar
- {
- public static void Register(IIocManager iocManager)
- {
- var services = new ServiceCollection();
- IdentityRegistrar.Register(services);
- services.AddEntityFrameworkInMemoryDatabase();
- var serviceProvider = WindsorRegistrationHelper.CreateServiceProvider(iocManager.IocContainer, services);
- var builder = new DbContextOptionsBuilder<ExamDbContext>();
- builder.UseInMemoryDatabase(Guid.NewGuid().ToString()).UseInternalServiceProvider(serviceProvider);
- iocManager.IocContainer.Register(
- Component
- .For<DbContextOptions<ExamDbContext>>()
- .Instance(builder.Options)
- .LifestyleSingleton()
- );
- }
- }
- }
|