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);
        }
Exemple #2
0
        public void Can_pass_null_args()
        {
            // Even though newer versions of the tools will pass an empty array
            // older versions of the tools can pass null args.
            var assembly = MockAssembly.Create(typeof(TestContext));

            _ = new TestDbContextOperations(
                new TestOperationReporter(),
                assembly,
                assembly,
                args: null,
                new TestAppServiceProviderFactory(assembly));
        }
        public void Can_pass_null_args()
        {
            // Even though newer versions of the tools will pass an empty array
            // older versions of the tools can pass null args.
            var assembly = MockAssembly.Create(typeof(TestContext));

            _ = new TestDbContextOperations(
                new TestOperationReporter(),
                assembly,
                assembly,
                projectDir: "",
                rootNamespace: null,
                language: "C#",
                nullable: false,
                args: null,
                new TestAppServiceProviderFactory(assembly));
        }
Exemple #4
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);
        }