public void Can_generate_schema() { Database.SetInitializer <SiteObjectContext>(null); var ctx = new SiteObjectContext("Test"); string result = ctx.CreateDatabaseScript(); result.ShouldNotBeNull(); }
public virtual void SetUp() { //TODO fix compilation warning (below) #pragma warning disable 0618 Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); context = new SiteObjectContext(GetTestDbName()); context.Database.Delete(); context.Database.Create(); }
/// <summary> /// Persistance test helper /// </summary> /// <typeparam name="T">Entity type</typeparam> /// <param name="entity">Entity</param> /// <param name="disposeContext">A value indicating whether to dispose context</param> protected T SaveAndLoadEntity <T>(T entity, bool disposeContext = true) where T : BaseEntity { context.Set <T>().Add(entity); context.SaveChanges(); object id = entity.Id; if (disposeContext) { context.Dispose(); context = new SiteObjectContext(GetTestDbName()); } var fromDb = context.Set <T>().Find(id); return(fromDb); }