示例#1
0
        public void ReInitializeBdd()
        {
            IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());
        }
示例#2
0
        static void Main(string[] args)
        {
            var contextFactory = new MigrationsContextFactory();

            using (var dbContext = contextFactory.Create())
            {
                try
                {
                    Console.WriteLine("Creating a database...");

                    var db = new DropCreateDatabaseAlways <ConsultationContext>();
                    db.InitializeDatabase(dbContext);
                    Database.SetInitializer(db);
                    new DemoDataHelper().CreateConsultationConfigData();
                    Console.WriteLine("Complete");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Something unexpected happened:");
                    Console.WriteLine(ex);
                }
                Console.WriteLine();
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }
示例#3
0
            public void Init_AvantChaqueTest()
            {
                IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

                Database.SetInitializer(init);
                init.InitializeDatabase(new BddContext());
            }
示例#4
0
        public void Initialize()
        {
            IDatabaseInitializer <AfCompContext> init = new DropCreateDatabaseAlways <AfCompContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new AfCompContext());
        }
示例#5
0
 public void Setup()
 {
     _dbContextScopeFactory    = new DbContextScopeFactory();
     _dropCreateDatabaseAlways = new DropCreateDatabaseAlways <BloggerDbContext>();
     Database.SetInitializer(_dropCreateDatabaseAlways);
     _context = new BloggerDbContext();
     _dropCreateDatabaseAlways.InitializeDatabase(_context);
 }
示例#6
0
        public void TestInitialize()
        {
            IDatabaseInitializer <LibraryContext> init = new DropCreateDatabaseAlways <LibraryContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new LibraryContext());
            dal = new LibraryDal();
        }
        public static LibraryDal TestInitializer()
        {
            IDatabaseInitializer <LibraryContext> init = new DropCreateDatabaseAlways <LibraryContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new LibraryContext());
            return(new LibraryDal());
        }
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer <PortofolioContext> init = new DropCreateDatabaseAlways <PortofolioContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new PortofolioContext());

            dal = new PortofolioServices();
        }
示例#9
0
        public void Init_BeforeEachTest()
        {
            IDatabaseInitializer <DatabaseContext> init = new DropCreateDatabaseAlways <DatabaseContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new DatabaseContext());

            dal = new Dal();
        }
示例#10
0
        public void Init_BeforeTest()
        {
            controllerToTest = new AuthenticateController();

            IDatabaseInitializer <SchoolContext> db = new DropCreateDatabaseAlways <SchoolContext>();

            Database.SetInitializer(db);
            db.InitializeDatabase(new SchoolContext());
        }
示例#11
0
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer <DbContextBis> init = new DropCreateDatabaseAlways <DbContextBis>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new DbContextBis());

            dal = new Dal();
        }
示例#12
0
        [TestInitialize] //cette "décoration" permet de dénir une methode qui sera executée avant chaque teste
        public void Init_AvantChaqueTest()
        {
            //reinitialisation de la base (efface tout dans le base) avant les teste
            IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            _dal = new Dal();
        }
示例#13
0
        public void Init_AvantChaqueTest()
        {
            accountBusiness  = new AccountBusiness();
            controllerToTest = new StudentsController();

            IDatabaseInitializer <SchoolContext> init = new DropCreateDatabaseAlways <SchoolContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new SchoolContext());
        }
示例#14
0
        public void InitializeDatabase(TContext context)
        {
            var step1 = new DropCreateDatabaseAlways <TContext>();

            step1.InitializeDatabase(context);

            var step2 = new MigrateDatabaseToLatestVersion <TContext, TMigrationsConfiguration>();

            step2.InitializeDatabase(context);
        }
示例#15
0
        protected void Application_Start()
        {
            IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
示例#16
0
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            // TODO : mettre en place la migration, asinsi qu'une méthode Seed
            // Car pour l'instant la réinitialisation de la Bdd lors du changement du Model
            // est très mal gérée (faire CTRL + F sur InitializeDataBase
        }
示例#17
0
        static public void initDbb()
        {
            SqlConnection.ClearAllPools();
            IDatabaseInitializer <DbbContext> init = new DropCreateDatabaseAlways <DbbContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new DbbContext());
            using (var ctx = new DbbContext())
            {
                ctx.Database.Initialize(force: true);
            }
        }
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer <Travail5Context> init = new DropCreateDatabaseAlways <Travail5Context>();

            Database.SetInitializer(init);

            Travail5Context database = new Travail5Context();

            init.InitializeDatabase(database);

            _repo = new MusiqueRepository(database);
        }
示例#19
0
        void Application_Start(object sender, EventArgs e)
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);

            IDatabaseInitializer <BddContext> init = new DropCreateDatabaseAlways <BddContext>();

            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());
            Dal d = new Dal();

            d.InitializeBdd();
        }
示例#20
0
        public void Setup(string connectionString)
        {
            DropCreateDatabaseAlways <MyDBdContext> strategy = new DropCreateDatabaseAlways <MyDBdContext>();

            if (connectionString is null)
            {
                throw new ArgumentNullException();
            }
            try
            {
                Database.SetInitializer(strategy);
                strategy.InitializeDatabase(new MyDBdContext(connectionString));
            }
            catch (Exception exception)
            {
                throw new UnavailableDbException("lol", exception.InnerException);
            }
        }
示例#21
0
        public void Setup(string connectionString)
        {
            if (connectionString is null)
            {
                throw new ArgumentNullException();
            }

            using (var context = new SiteContext(connectionString))
            {
                DropCreateDatabaseAlways <SiteContext> db = new DropCreateDatabaseAlways <SiteContext>();
                Database.SetInitializer <SiteContext>(null);
                try
                {
                    db.InitializeDatabase(context);
                }
                catch (SqlException)
                {
                    throw new UnavailableDbException();
                }
            }
        }
        public static void Reset()
        {
            IDatabaseInitializer<DatabaseContext> init = new DropCreateDatabaseAlways<DatabaseContext>();
            System.Data.Entity.Database.SetInitializer(init);
            init.InitializeDatabase(new DatabaseContext());

            string connectionString = CloudConfigurationManager.GetSetting("StorageConnectionString");
            #if DEBUG
            Console.WriteLine("StorageConnectionString : {0}", connectionString);
            Trace.TraceInformation("StorageConnectionString : {0}", connectionString);
            #endif
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            foreach(string containerName in new []{"images", "sounds"})
            {
                CloudBlobContainer container = blobClient.GetContainerReference(containerName);
                if (container.Exists())
                {
                    container.Delete();
                }
            }
        }
示例#23
0
        public void Init_AvantChaqueTest()
        {
            IDatabaseInitializer<BddContext> init = new DropCreateDatabaseAlways<BddContext>();
            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            dal = new Dal();
        }
示例#24
0
        public void Init_BeforeEachTest()
        {
            // On créer et supprimer la base de donnée a chaque lancement des tests.
            IDatabaseInitializer<BddContext> init = new DropCreateDatabaseAlways<BddContext>();
            Database.SetInitializer(init);
            init.InitializeDatabase(new BddContext());

            _dal = new Dal();
        }
示例#25
0
        static void Main()
        {
            Console.WriteLine("Creating Database first");
            //Creating database first
            var dropCreateDatabaseAlways = new DropCreateDatabaseAlways <BloggerDbContext>();

            Database.SetInitializer(dropCreateDatabaseAlways);
            var context = new BloggerDbContext();

            dropCreateDatabaseAlways.InitializeDatabase(context);

            //Creating an user
            Console.WriteLine("Creating an user");
            IUserServices userRepository = new UserServices();
            var           userId         = userRepository.AddUser(new VoUser
            {
                Name       = "TestUser",
                Occupation = "Software Developer"
            });

            //Creating a blog and its post
            Console.WriteLine("Creating a blog post");
            IBlogServices blogRepository = new BlogServices();
            var           blog           = new VoBlog
            {
                CreatedDateTime = DateTime.Now,
                Overview        = "This is a sample overview.",
                Post            = new VoPost
                {
                    Meta             = "Sample, Test",
                    Content          = "This is a sample overview",
                    ShortDescription = "This is a sample short description",
                    Title            = "Test Title"
                },
                UserId = userId
            };

            blogRepository.AddBlog(blog);

            //Retrieving the user in an async mode. This is where thread switching happens
            Console.WriteLine("Retrieving the created user");
            var user = userRepository.GetUserAsync(userId).ConfigureAwait(false);

            Console.WriteLine("Name of the created user is " + user.GetAwaiter().GetResult().Name);

            //Get the user's most recent blog
            Console.WriteLine("Retrieving the user most recent blog");
            var recentBlog = blogRepository.GetUserRecentBlog(userId);

            Console.WriteLine("Overview " + recentBlog.Overview);
            Console.WriteLine("BlogPost Meta " + recentBlog.Post.Meta);
            Console.WriteLine("BlogPost Short Description " + recentBlog.Post.ShortDescription);
            Console.WriteLine("BlogPost Content " + recentBlog.Post.Content);

            //Create a blog and try to save it. If the creation fails , update the  creation failure count in the user profile.
            var blog2 = new VoBlog
            {
                CreatedDateTime = DateTime.Now,
                Post            = new VoPost
                {
                    Meta             = "Sample, Test",
                    Content          = "This is a sample overview",
                    ShortDescription = "This is a sample short description",
                    Title            = "Test Title"
                },
                UserId = userId
            };

            try
            {
                blogRepository.AddBlog(blog2);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
            Console.ReadKey();
        }