public static void SeedTests(this ContractEditorDb context) { //Add contracts context.ContractFileSessions.Add(new ContractFileSession() { Id = "expired", ExpirationDate = DateTime.MinValue }); context.ContractFileSessions.Add(new ContractFileSession() { Id = "contract-1", SerializedContract = "serialized-contract-1" }); context.ContractFileSessions.Add(new ContractFileSession() { Id = "contract-2", SerializedContract = "serialized-contract-2" }); context.ContractFileSessions.Add(new ContractFileSession() { Id = "contract-3", SerializedContract = "serialized-contract-3" }); context.SaveChanges(); }
public ContractEditorDb Build() { //SQLite if (!testingDatabaseAlreadyCreated) { SQLiteConnection.CreateFile(testingDatabaseName); } var connection = new SQLiteConnection("DataSource=" + testingDatabaseName); connection.Open(); SQLiteDbConnections.Add(connection); var options = new DbContextOptionsBuilder <ContractEditorDb>() .UseSqlite(connection) .EnableSensitiveDataLogging() .Options; //Build context var context = new ContractEditorDb(options); context.Database.CloseConnection(); context.Database.EnsureCreated(); context.Database.GetDbConnection(); //Seed if (!testingDatabaseAlreadyCreated) { context.SeedTests(); } contexts.Add(context); testingDatabaseAlreadyCreated = true; return(context); }
public ContractFileSessionRepository(ContractEditorDb context) { this.context = context; }