public DoctrinaDbContext GetDbContext(bool useSqlLite = false) { var builder = new DbContextOptionsBuilder <DoctrinaDbContext>(); if (useSqlLite) { builder.UseSqlite("DataSource=:memory:", x => { }); } else { builder.UseInMemoryDatabase(Guid.NewGuid().ToString()); } var dbContext = new DoctrinaDbContext(builder.Options); if (useSqlLite) { // SQLite needs to open connection to the DB. // Not required for in-memory-database. dbContext.Database.OpenConnection(); } dbContext.Database.EnsureCreated(); return(dbContext); }
public static DoctrinaDbContext Create() { var options = new DbContextOptionsBuilder <DoctrinaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new DoctrinaDbContext(options); context.Database.EnsureCreated(); var activityId = new Iri("http://www.example.com/activityId/hashset"); context.Activities.Add(new ActivityEntity() { Id = activityId.ToString(), Hash = activityId.ComputeHash() }); context.Agents.AddRange(new AgentEntity[] { AgentsTestFixture.JamesCampbell(), AgentsTestFixture.JosephinaCampbell() }); context.SaveChanges(); return(context); }
public static DoctrinaDbContext Create() { var options = new DbContextOptionsBuilder <DoctrinaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new DoctrinaDbContext(options); context.Database.EnsureCreated(); // TODO: Parse statements from file, and map to entities. //var collection = new StatementCollection(); context.SaveChanges(); return(context); }
public static DoctrinaDbContext Create() { var options = new DbContextOptionsBuilder <DoctrinaDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new DoctrinaDbContext(options); context.Database.EnsureCreated(); //context.Statements.AddRange(new[] { //}); context.SaveChanges(); return(context); }
public EntityFrameworkCoreDbProvider(DoctrinaDbContext dbContext) { this.dbContext = dbContext; }
public static void Destroy(DoctrinaDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public CommandTestBase() { _context = DoctrinaContextFactory.Create(); }
public CreateStatementsCommandHandler(DoctrinaDbContext context, IMediator mediator) { _context = context; _mediator = mediator; }
public CommandTestBase() { _context = DoctrinaContextFactory.Create(); _mapper = AutoMapperFactory.Create(); }