コード例 #1
0
        public void CreateContext_uses_exact_factory_method()
        {
            var assembly   = MockAssembly.Create(typeof(BaseContext), typeof(DerivedContext), typeof(HierarchyContextFactory));
            var operations = new TestDbContextOperations(
                new TestOperationReporter(),
                assembly,
                assembly,
                args: Array.Empty <string>(),
                new TestAppServiceProviderFactory(assembly));

            var baseContext = Assert.IsType <BaseContext>(operations.CreateContext(nameof(BaseContext)));

            Assert.Equal(nameof(BaseContext), baseContext.FactoryUsed);

            var derivedContext = Assert.IsType <DerivedContext>(operations.CreateContext(nameof(DerivedContext)));

            Assert.Equal(nameof(DerivedContext), derivedContext.FactoryUsed);
        }
コード例 #2
0
        public void CreateContext_gets_service()
        {
            var assembly   = MockAssembly.Create(typeof(TestProgram), typeof(TestContext));
            var operations = new TestDbContextOperations(
                new TestOperationReporter(),
                assembly,
                assembly,
                new TestAppServiceProviderFactory(assembly, typeof(TestProgram)));

            operations.CreateContext(typeof(TestContext).FullName);
        }