示例#1
0
        private void ValidateContextNameInReverseEngineerGenerator(string contextName)
        {
            var cSharpUtilities = new CSharpUtilities();
            var reverseEngineer = new ReverseEngineerScaffolder(
                new RelationalDatabaseModelFactoryTest.FakeDatabaseModelFactory(),
                new RelationalDatabaseModelFactoryTest.FakeScaffoldingModelFactory(new TestOperationReporter()),
                new CSharpScaffoldingGenerator(
                    new InMemoryFileService(),
                    new CSharpDbContextGenerator(new FakeScaffoldingCodeGenerator(), new FakeAnnotationCodeGenerator(), cSharpUtilities),
                    new CSharpEntityTypeGenerator(cSharpUtilities)),
                cSharpUtilities);

            Assert.Equal(
                DesignStrings.ContextClassNotValidCSharpIdentifier(contextName),
                Assert.Throws <ArgumentException>(
                    () => reverseEngineer.Generate(
                        connectionString: "connectionstring",
                        tables: Enumerable.Empty <string>(),
                        schemas: Enumerable.Empty <string>(),
                        projectPath: "FakeProjectPath",
                        outputPath: null,
                        rootNamespace: "FakeNamespace",
                        contextName: contextName,
                        useDataAnnotations: false,
                        overwriteFiles: false,
                        useDatabaseNames: false))
                .Message);
        }
示例#2
0
        private void ValidateContextNameInReverseEngineerGenerator(string contextName)
        {
            var cSharpUtilities = new CSharpUtilities();
            var reverseEngineer = new ReverseEngineerScaffolder(
                new FakeDatabaseModelFactory(),
                new FakeScaffoldingModelFactory(new TestOperationReporter()),
                new ScaffoldingCodeGeneratorSelector(
                    new[]
            {
                new CSharpScaffoldingGenerator(
                    new CSharpDbContextGenerator(
#pragma warning disable CS0618 // Type or member is obsolete
                        Enumerable.Empty <IScaffoldingProviderCodeGenerator>(),
#pragma warning restore CS0618 // Type or member is obsolete
                        new[] { new TestProviderCodeGenerator() },
                        new FakeAnnotationCodeGenerator(), cSharpUtilities),
                    new CSharpEntityTypeGenerator(cSharpUtilities))
            }),
                cSharpUtilities);

            Assert.Equal(
                DesignStrings.ContextClassNotValidCSharpIdentifier(contextName),
                Assert.Throws <ArgumentException>(
                    () => reverseEngineer.Generate(
                        connectionString: "connectionstring",
                        tables: Enumerable.Empty <string>(),
                        schemas: Enumerable.Empty <string>(),
                        projectPath: "FakeProjectPath",
                        outputPath: null,
                        rootNamespace: "FakeNamespace",
                        language: "",
                        contextName: contextName,
                        useDataAnnotations: false,
                        useDatabaseNames: false))
                .Message);
        }