Exemplo n.º 1
0
        public void Can_generate_schema()
        {
            Database.SetInitializer <SiteObjectContext>(null);
            var    ctx    = new SiteObjectContext("Test");
            string result = ctx.CreateDatabaseScript();

            result.ShouldNotBeNull();
        }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
        /// <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);
        }