Beispiel #1
0
        private void SetUpClient()
        {
            IOptions <OperationalStoreOptions> options = Options.Create <OperationalStoreOptions>(new OperationalStoreOptions());

            var builder = new WebHostBuilder()
                          .UseStartup <PoliciesWebApp.Startup>()
                          .ConfigureServices(services =>
            {
                var context = new PoliciesDbContext(
                    new DbContextOptionsBuilder <PoliciesDbContext>()
                    .UseSqlite("DataSource=:memory:")
                    .EnableSensitiveDataLogging()
                    .Options,
                    options);

                services.RemoveAll(typeof(PoliciesDbContext));
                services.AddSingleton(context);
                context.Database.OpenConnection();
                context.Database.EnsureCreated();
                context.SaveChanges();
                foreach (var entity in context.ChangeTracker.Entries().ToList())
                {
                    entity.State = EntityState.Detached;
                }
            });

            _server = new TestServer(builder);
            Client  = _server.CreateClient();
        }
Beispiel #2
0
 public SqlPoliciesRepo(PoliciesDbContext policiesDbContext)
 {
     _policiesDbContext = policiesDbContext;
 }