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); }
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); }