예제 #1
0
        public PreceptorTimeContextFactory()
        {
            //Notice that we are building ContextOptions using Guid.NewGuid().ToString() property as a database
            //name in order to provide a new, clean in-memory instance for each test class.
            var contextOptions = new DbContextOptionsBuilder <PreceptorTimeContext>()
                                 .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                 .EnableSensitiveDataLogging()
                                 .Options;

            EnsureCreation(contextOptions);
            ContextInstance = new TestPreceptorTimeContext(contextOptions);

            ReportMapper    = new ReportMapper();
            UserInfoMapper  = new UserInfoMapper();
            UserMapper      = new UserMapper();
            TimeEntryMapper = new TimeEntryMapper(UserMapper);
        }
예제 #2
0
 private void EnsureCreation(DbContextOptions <PreceptorTimeContext> contextOptions)
 {
     using var context = new TestPreceptorTimeContext(contextOptions);
     context.Database.EnsureCreated();
 }