public void TestAreaGenerator()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    TestProjectPath,
                    "-c",
                    Configuration,
                    "area",
                    "Admin"
                };

                Scaffold(args, TestProjectPath);
                var generatedFilePath = Path.Combine(TestProjectPath, "ScaffoldingReadMe.txt");
                var baselinePath      = Path.Combine("ReadMe", "Readme.txt");

                var foldersToVerify = new string[]
                {
                    Path.Combine(TestProjectPath, "Areas", "Admin", "Controllers"),
                    Path.Combine(TestProjectPath, "Areas", "Admin", "Data"),
                    Path.Combine(TestProjectPath, "Areas", "Admin", "Models"),
                    Path.Combine(TestProjectPath, "Areas", "Admin", "Views")
                };

                VerifyFileAndContent(generatedFilePath, baselinePath);
                foreach (var folder in foldersToVerify)
                {
                    VerifyFoldersCreated(folder);
                }
            }
        }
        public void TestControllerWithContext_WithForeignKey()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output, false);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                Directory.SetCurrentDirectory(TestProjectPath);
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "controller",
                    "--controllerName",
                    "ProductsController",
                    "--model",
                    "WebApplication1.Models.Product",
                    "--dataContext",
                    "WebApplication1.Models.ProductContext"
                };

                Scaffold(args, TestProjectPath);

                var generatedFilePath = Path.Combine(TestProjectPath, "ProductsController.cs");
                var viewFolder        = Path.Combine(TestProjectPath, "Views", "Products");

                VerifyFileAndContent(generatedFilePath, "ProductsController.txt");
                VerifyFileAndContent(Path.Combine(viewFolder, "Create.cshtml"), Path.Combine("ProductViews", "Create.cshtml"));
                VerifyFileAndContent(Path.Combine(viewFolder, "Delete.cshtml"), Path.Combine("ProductViews", "Delete.cshtml"));
                VerifyFileAndContent(Path.Combine(viewFolder, "Details.cshtml"), Path.Combine("ProductViews", "Details.cshtml"));
                VerifyFileAndContent(Path.Combine(viewFolder, "Edit.cshtml"), Path.Combine("ProductViews", "Edit.cshtml"));
                VerifyFileAndContent(Path.Combine(viewFolder, "Index.cshtml"), Path.Combine("ProductViews", "Index.cshtml"));
            }
        }
        public void TestIdentityGenerator()
        {
            string runSkippableTests = Environment.GetEnvironmentVariable("SCAFFOLDING_RunSkippableTests");

            Skip.If(string.IsNullOrEmpty(runSkippableTests));

            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsForIdentityScaffolder(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "identity",
                    "--generateLayout",
                    "-f"
                };

                Scaffold(args, TestProjectPath);

                foreach (var file in IdentityGeneratorFilesConfig.Templates)
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Template file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }

                foreach (var file in IdentityGeneratorFilesConfig.StaticFiles(IdentityGeneratorFilesConfig.LayoutFileDisposition.Generate))
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Static file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }
            }
        }
        public void TestGetProjectReferenceInformation(string rootProjectPath, string libraryDirectoryPath, string relativePathToLibrary)
        {
            using (var temporaryFileProvider = new TemporaryFileProvider())
            {
                rootProjectPath = Path.Combine(temporaryFileProvider.Root, rootProjectPath);
                Directory.CreateDirectory(Path.Combine(
                                              temporaryFileProvider.Root,
                                              libraryDirectoryPath,
                                              "Library1"));
                Directory.CreateDirectory(Path.Combine(
                                              temporaryFileProvider.Root,
                                              libraryDirectoryPath,
                                              "Library2"));

                AddProject(
                    $"{libraryDirectoryPath}/Library1/Library1.csproj",
                    ProjectReference1,
                    temporaryFileProvider);
                AddProject(
                    $"{libraryDirectoryPath}/Library2/Library2.csproj",
                    ProjectReference1,
                    temporaryFileProvider);
                var projectReferenceInformation = ProjectReferenceInformationProvider.GetProjectReferenceInformation(
                    rootProjectPath,
                    new string[] { relativePathToLibrary });

                Assert.NotNull(projectReferenceInformation);
            }
        }
Exemple #5
0
        //[Theory, MemberData(nameof(TestData))]
        public void TestIdentityGenerator_IndividualFiles_AllFilesBuild(string fileName)
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsForIdentityScaffolder(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");

                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "identity",
                    "--dbContext",
                    "Test.Data.MyApplicationDbContext",
                    "--files",
                    fileName
                };

                Scaffold(args, TestProjectPath);

                var result = Command.CreateDotNet("build", new string[] { "-c", Configuration })
                             .WithEnvironmentVariable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", "true")
                             .InWorkingDirectory(TestProjectPath)
                             .OnErrorLine(l => Output.WriteLine(l))
                             .OnOutputLine(l => Output.WriteLine(l))
                             .Execute();

                if (result.ExitCode != 0)
                {
                    throw new InvalidOperationException($"Build failed with exit code: {result.ExitCode}");
                }
            }
        }
Exemple #6
0
        public void TestIdentityGenerator_IndividualFiles()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsForIdentityScaffolder(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "identity",
                    "--dbContext",
                    "Test.Data.MyApplicationDbContext",
                    "--files",
                    "Account.Login;Account.Manage.PersonalData"
                };

                Scaffold(args, TestProjectPath);

                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "Login.cshtml")));
                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "Login.cshtml.cs")));

                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "Manage", "PersonalData.cshtml")));
                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "Manage", "PersonalData.cshtml.cs")));

                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "Manage", "_ViewImports.cshtml")));
                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "Account", "_ViewImports.cshtml")));
                Assert.True(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Pages", "_ViewImports.cshtml")));
            }
        }
Exemple #7
0
        public async void TestGetModelMetadata_WithoutDbContext()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                SetupProjects(fileProvider);

                var appName          = MsBuildProjectStrings.RootProjectName;
                var path             = Path.Combine(fileProvider.Root, "Root", appName);
                var CodeModelService = GetCodeModelService(path, appName);
                var modelType        = _modelTypesLocator.GetType("ModelWithMatchingShortName").First();
                var metadata         = await CodeModelService.GetModelMetadata(modelType);

                Assert.Equal(ContextProcessingStatus.ContextAvailable, metadata.ContextProcessingStatus);
                Assert.False(metadata.ModelMetadata.Navigations.Any());
                Assert.False(metadata.ModelMetadata.Properties.Any());

                modelType = _modelTypesLocator.GetType("Library1.Models.Car").First();
                metadata  = await CodeModelService.GetModelMetadata(modelType);

                Assert.Equal(ContextProcessingStatus.ContextAvailable, metadata.ContextProcessingStatus);
                Assert.False(metadata.ModelMetadata.Navigations.Any());
                Assert.False(metadata.ModelMetadata.PrimaryKeys.Any());
                Assert.Equal(3, metadata.ModelMetadata.Properties.Length);
            }
        }
        public void TestControllerWithoutEf()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsWithoutEF(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                Directory.SetCurrentDirectory(TestProjectPath);
                System.Console.WriteLine(fileProvider.Root);
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "controller",
                    "--controllerName",
                    "ActionsController",
                    "--readWriteActions",
                    "--bootstrapVersion",
                    "3"
                };

                Scaffold(args, TestProjectPath);

                var generatedFilePath = Path.Combine(TestProjectPath, "ActionsController.cs");

                VerifyFileAndContent(generatedFilePath, "ReadWriteController.txt");
            }
        }
        public void TestGetReflectedType_FailedCompilation()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                SetupProjectInformation(fileProvider);

                var compilation = _workspace.CurrentSolution.Projects
                                  .First()
                                  .GetCompilationAsync()
                                  .Result;

                Func <CodeAnalysis.Compilation, CodeAnalysis.Compilation> func = (c) =>
                {
                    return(c.WithReferences(null));
                };

                var reflectedTypesProvider = new ReflectedTypesProvider(
                    compilation,
                    func,
                    _projectContext,
                    _loader,
                    _logger);

                var carType = reflectedTypesProvider.GetReflectedType("Library1.Models.Car", true);
                Assert.Null(carType);

                var compilationErrors = reflectedTypesProvider.GetCompilationErrors();
                Assert.NotNull(compilationErrors);
            }
        }
        public void TestIdentityGenerator()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsForIdentityScaffolder(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "identity"
                };

                Scaffold(args, TestProjectPath);

                foreach (var file in IdentityGeneratorFilesConfig.Templates)
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Template file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }

                foreach (var file in IdentityGeneratorFilesConfig.StaticFiles)
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Static file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }
            }
        }
        public void TestControllerWithContext()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "aspnet-codegenerator",
                    "-p",
                    TestProjectPath,
                    "-c",
                    Configuration,
                    "controller",
                    "--controllerName",
                    "CarsController",
                    "--model",
                    "Library1.Models.Car",
                    "--dataContext",
                    "WebApplication1.Models.CarContext",
                    "--noViews"
                };

                Scaffold(args, TestProjectPath);
                var generatedFilePath = Path.Combine(TestProjectPath, "CarsController.cs");
                VerifyFileAndContent(generatedFilePath, "CarsController.txt");
            }
        }
        public void TestControllerWithoutContext()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    TestProjectPath,
                    "-c",
                    Configuration,
                    "--simulation-mode",
                    "controller",
                    "--controllerName",
                    "CarsController",
                    "--relativeFolderPath",
                    "SimControllers"
                };

                Scaffold(args, TestProjectPath);
                var controllerDir = Path.Combine(TestProjectPath, "SimControllers");
                Console.WriteLine($"ControllerDirectory: {controllerDir}");
                Assert.False(Directory.Exists(controllerDir));
                Assert.False(File.Exists(Path.Combine(controllerDir, "CarsController.cs")));
            }
        }
        public void TestControllerWithContext()
        {
            string runSkippableTests = Environment.GetEnvironmentVariable("SCAFFOLDING_RunSkippableTests");

            Skip.If(string.IsNullOrEmpty(runSkippableTests));

            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "controller",
                    "--controllerName",
                    "CarsController",
                    "--model",
                    "Library1.Models.Car",
                    "--dataContext",
                    "WebApplication1.Models.CarContext",
                    "--noViews",
                    "--bootstrapVersion",
                    "3"
                };

                Scaffold(args, TestProjectPath);
                var generatedFilePath = Path.Combine(TestProjectPath, "CarsController.cs");
                VerifyFileAndContent(generatedFilePath, "CarsController.txt");
            }
        }
Exemple #14
0
        public void TestIdentityGenerator_WithExistingUser()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjectsForIdentityScaffolder(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "identity",
                    "-u",
                    "Test.Data.MyIdentityUser",
                    "--generateLayout",
                    "-f"
                };

                Scaffold(args, TestProjectPath);

                foreach (var file in IdentityGeneratorFilesConfig.Templates)
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Template file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }

                foreach (var file in IdentityGeneratorFilesConfig.StaticFiles(IdentityGeneratorFilesConfig.LayoutFileDisposition.Generate))
                {
                    Assert.True(File.Exists(Path.Combine(TestProjectPath, file)), $"Static file does not exist: '{Path.Combine(TestProjectPath, file)}'");
                }

                Assert.False(File.Exists(Path.Combine(TestProjectPath, "Areas", "Identity", "Data", "MyIdentityUser.cs")));
            }
        }
        public void TestApiController()
        {
            var controllerName = "TestApiController";

            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var args = new string[]
                {
                    "-p",
                    Path.Combine(TestProjectPath, "Test.csproj"),
                    "-c",
                    Configuration,
                    "controller",
                    "--controllerName",
                    controllerName,
                    "--model",
                    "Library1.Models.Car",
                    "--dataContext",
                    "WebApplication1.Models.CarContext",
                    "--restWithNoViews",
                    "--bootstrapVersion",
                    "3"
                };

                Scaffold(args, TestProjectPath);
                var generatedFilePath = Path.Combine(TestProjectPath, $"{controllerName}.cs");
                VerifyFileAndContent(generatedFilePath, $"{controllerName}.txt");
            }
        }
Exemple #16
0
    public void ThrowsWhenRootDoesNotExist()
    {
        var files  = new TemporaryFileProvider();
        var finder = new MsBuildProjectFinder(files.Root);

        files.Dispose();
        Assert.Throws <FileNotFoundException>(() => finder.FindMsBuildProject(null));
    }
Exemple #17
0
    public void ThrowsWhenFileDoesNotExist()
    {
        using (var files = new TemporaryFileProvider())
        {
            var finder = new MsBuildProjectFinder(files.Root);

            Assert.Throws <FileNotFoundException>(() => finder.FindMsBuildProject("test.csproj"));
        }
    }
Exemple #18
0
    public void ThrowsWhenNoFile()
    {
        using (var files = new TemporaryFileProvider())
        {
            var finder = new MsBuildProjectFinder(files.Root);

            Assert.Throws <FileNotFoundException>(() => finder.FindMsBuildProject(null));
        }
    }
        public void ThrowsWhenNoFile()
        {
            using (var files = new TemporaryFileProvider())
            {
                var finder = new MsBuildProjectFinder(files.Root);

                Assert.Throws <InvalidOperationException>(() => finder.FindMsBuildProject());
            }
        }
Exemple #20
0
    public void DoesNotMatchXproj()
    {
        using (var files = new TemporaryFileProvider())
        {
            var finder = new MsBuildProjectFinder(files.Root);
            files.Add("test.xproj", "");

            Assert.Throws <FileNotFoundException>(() => finder.FindMsBuildProject(null));
        }
    }
 public void GetPathTestOSX(string nugetPath, string packageName, string version, string expectedPath)
 {
     Skip.If(!RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || !RuntimeInformation.IsOSPlatform(OSPlatform.Linux));
     using (var fileProvider = new TemporaryFileProvider())
     {
         Tuple <string, string> nameAndVersion = new Tuple <string, string>(packageName, version);
         ProjectContextWriter   writer         = new ProjectContextWriter();
         Assert.Equal(expectedPath, writer.GetPath(nugetPath, nameAndVersion));
     }
 }
Exemple #22
0
 public void TestViewGenerator(string baselineFile, string generatedFilePath, string[] args)
 {
     using (var fileProvider = new TemporaryFileProvider())
     {
         new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
         TestProjectPath = Path.Combine(fileProvider.Root, "Root");
         Scaffold(args, TestProjectPath);
         generatedFilePath = Path.Combine(TestProjectPath, generatedFilePath);
         VerifyFileAndContent(generatedFilePath, baselineFile);
     }
 }
Exemple #23
0
    public void ThrowsWhenMultipleFile()
    {
        using (var files = new TemporaryFileProvider())
        {
            files.Add("Test1.csproj", "");
            files.Add("Test2.csproj", "");
            var finder = new MsBuildProjectFinder(files.Root);

            Assert.Throws <FileNotFoundException>(() => finder.FindMsBuildProject(null));
        }
    }
        private void SetupProjectInformation(TemporaryFileProvider fileProvider)
        {
            _projectSetupHelper.SetupProjects(fileProvider, _output);

            var path = Path.Combine(fileProvider.Root, "Root", "Test.csproj");

            _projectContext = GetProjectInformation(path);
            _workspace      = new RoslynWorkspace(_projectContext);
            _loader         = new TestAssemblyLoadContext(_projectContext);
            _logger         = new ConsoleLogger();
        }
 public void TestRazorPagesWithDbContextInDependency()
 {
     using (var fileProvider = new TemporaryFileProvider())
     {
         new MsBuildProjectSetupHelper().SetupProjectsWithDbContextInDependency(fileProvider, Output);
         TestProjectPath = Path.Combine(fileProvider.Root, "Root");
         Scaffold(PAGE_WITH_DATACONTEXT_IN_DEPENDENCY, TestProjectPath);
         VerifyFileAndContent(Path.Combine(TestProjectPath, "CarCreate.cshtml"), Path.Combine("RazorPages", "CarCreate.txt"));
         VerifyFileAndContent(Path.Combine(TestProjectPath, "CarCreate.cshtml.cs"), Path.Combine("RazorPages", "CarCreateCsWithDAL.txt"));
     }
 }
Exemple #26
0
    public void FindsSingleProject(string extension)
    {
        using (var files = new TemporaryFileProvider())
        {
            var filename = "TestProject" + extension;
            files.Add(filename, "");

            var finder = new MsBuildProjectFinder(files.Root);

            Assert.Equal(Path.Combine(files.Root, filename), finder.FindMsBuildProject(null));
        }
    }
        public void TestControllerGenerators(string baselineFile, string generatedFilePath, string[] args)
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
                TestProjectPath = Path.Combine(fileProvider.Root, "Root");
                var invocationArgs = new [] { "-p", Path.Combine(TestProjectPath, "Test.csproj") }.Concat(args).ToArray();
                Scaffold(invocationArgs, TestProjectPath);

                generatedFilePath = Path.Combine(TestProjectPath, generatedFilePath);
                VerifyFileAndContent(generatedFilePath, baselineFile);
            }
        }
 public void TestViewGenerator(string[] baselineFiles, string[] generatedFilePaths, string[] args)
 {
     using (var fileProvider = new TemporaryFileProvider())
     {
         new MsBuildProjectSetupHelper().SetupProjects(fileProvider, Output);
         TestProjectPath = Path.Combine(fileProvider.Root, "Root");
         Scaffold(args, TestProjectPath);
         for (int i = 0; i < generatedFilePaths.Length; i++)
         {
             var generatedFilePath = Path.Combine(TestProjectPath, generatedFilePaths[i]);
             VerifyFileAndContent(generatedFilePath, baselineFiles[i]);
         }
     }
 }
        public async Task TestValidateAndBuild()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                SetupProjects(fileProvider);

                var workspace = GetWorkspace(Path.Combine(fileProvider.Root, "Root"));

                var commandLineModel = new IdentityGeneratorCommandLineModel()
                {
                    RootNamespace = "Test.Namespace",
                    UseSQLite     = false
                };

                var applicationInfo = new ApplicationInfo("TestApp", "Sample");

                var builder = new IdentityGeneratorTemplateModelBuilder(
                    commandLineModel,
                    applicationInfo,
                    _projectContext,
                    workspace,
                    _loader,
                    new DefaultFileSystem(),
                    _logger.Object);

                var templateModel = await builder.ValidateAndBuild();

                Assert.Equal(commandLineModel.RootNamespace, templateModel.Namespace);
                Assert.Equal("TestAppIdentityDbContext", templateModel.DbContextClass);
                Assert.Equal("Test.Namespace.Areas.Identity.Data", templateModel.DbContextNamespace);
                Assert.False(templateModel.IsUsingExistingDbContext);

                Assert.Equal("IdentityUser", templateModel.UserClass);
                Assert.False(templateModel.IsGenerateCustomUser);

                commandLineModel.UserClass = "MyIdentityUser";

                templateModel = await builder.ValidateAndBuild();

                Assert.Equal("Test.Namespace.Areas.Identity.Data", templateModel.DbContextNamespace);
                Assert.False(templateModel.IsUsingExistingDbContext);

                Assert.Equal("MyIdentityUser", templateModel.UserClass);
                Assert.True(templateModel.IsGenerateCustomUser);
                Assert.False(templateModel.IsGeneratingIndividualFiles);
            }
        }
        public void TestProjectContextFromMsBuild()
        {
            using (var fileProvider = new TemporaryFileProvider())
            {
                new MsBuildProjectSetupHelper().SetupEmptyCodeGenerationProject(fileProvider, _outputHelper);
                var path = Path.Combine(fileProvider.Root, MsBuildProjectStrings.RootProjectName);

                var projectContext = GetProjectContext(path, true);
                //we know the project name is Test so test some basic properties.
                Assert.True(string.Equals(projectContext.DepsFile, "Test.deps.json", StringComparison.OrdinalIgnoreCase));
                Assert.True(string.Equals(projectContext.RuntimeConfig, "Test.runtimeconfig.json", StringComparison.OrdinalIgnoreCase));
                Assert.False(string.IsNullOrEmpty(projectContext.TargetFramework));
                Assert.True(projectContext.PackageDependencies.Any());
                Assert.True(projectContext.CompilationAssemblies.Any());
                Assert.True(projectContext.PackageDependencies.Where(x => x.Name.Equals("Microsoft.VisualStudio.Web.CodeGeneration.Design")).Any());
            }
        }