Example #1
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 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)}'");
                }
            }
        }