Пример #1
0
        /// <summary>
        /// Produces TestQuestedContexts
        /// </summary>
        public QuestedContextFactory()
        {
            var contextOptions = new DbContextOptionsBuilder <QuestedContext>()
                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                 .Options;

            EnsureCreation(contextOptions);
            ContextInstance = new TestQuestedContext(contextOptions);
            PupilMapper     = new PupilMapper();
            SchoolMapper    = new SchoolMapper();
            TeacherMapper   = new TeacherMapper();
            ClassMapper     = new ClassMapper();
            CourseMapper    = new CourseMapper();
        }
Пример #2
0
 /// <summary>
 /// Ensures that the database for given context exists. If it does not,
 /// it will be created
 /// </summary>
 /// <param name="contextOptions">configuration of database context</param>
 private void EnsureCreation(DbContextOptions <QuestedContext> contextOptions)
 {
     using var context = new TestQuestedContext(contextOptions);
     context.Database.EnsureCreated();
 }