示例#1
0
        public void CanFilterType()
        {
            var commandResult = new DotnetNewCommand(_log, "console", "--search", "--columns", "type", "--type", "item")
                                .WithCustomHive(_sharedHome.HomeDirectory)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOutContaining("Searching for the templates...")
            .And.HaveStdOutContaining("Matches from template source: NuGet.org")
            .And.HaveStdOutMatching("Template Name\\s+Short Name\\s+Type\\s+Package\\s+Downloads")
            .And.HaveStdOutContaining("To use the template, run the following command to install the package: dotnet new3 -i <package>");

            var tableOutput = ParseTableOutput(commandResult.StdOut, expectedColumns: new[] { "Template Name", "Short Name", "Type", "Package", "Downloads" });

            Assert.True(AllRowsContain(tableOutput, new[] { "Template Name", "Short Name" }, "console"), "'Template Name' or 'Short Name' columns do not contain the criteria");
            Assert.True(AllRowsEqual(tableOutput, new[] { "Type" }, "item"), "'Type' column does not contain criteria");

            Assert.True(AllRowsAreNotEmpty(tableOutput, "Template Name"), "'Template Name' column contains empty values");
            Assert.True(AllRowsAreNotEmpty(tableOutput, "Short Name"), "'Short Name' column contains empty values");
            Assert.True(AllRowsAreNotEmpty(tableOutput, "Type"), "'Type' column contains empty values");
            Assert.True(AllRowsAreNotEmpty(tableOutput, "Package"), "'Package' column contains empty values");
            Assert.True(AllRowsAreNotEmpty(tableOutput, "Downloads"), "'Downloads' column contains empty values");
        }
        public Task CannotInstallSameSourceTwice_Folder()
        {
            var    home        = TestUtils.CreateTemporaryFolder("Home");
            string basicFSharp = TestUtils.GetTestTemplateLocation("TemplateResolution/DifferentLanguagesGroup/BasicFSharp");

            new DotnetNewCommand(_log, "install", basicFSharp)
            .WithCustomHive(home)
            .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
            .Execute()
            .Should()
            .ExitWith(0)
            .And
            .NotHaveStdErr()
            .And.HaveStdOutContaining("basic");

            new DotnetNewCommand(_log, "install", basicFSharp)
            .WithCustomHive(home)
            .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
            .Execute()
            .Should().Fail()
            .And.HaveStdErrContaining($"{basicFSharp} is already installed");

            var commandResult = new DotnetNewCommand(_log, "install", basicFSharp)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .Execute();

            commandResult.Should().Fail();
            return(Verifier.Verify(commandResult.StdErr, _verifySettings)
                   .AddScrubber(output => output.ScrubAndReplace(basicFSharp, "%TEMPLATE FOLDER%")));
        }
示例#3
0
        public void ExamplePrefersMicrosoftPackage()
        {
            var commandResult = new DotnetNewCommand(_log, "azure", "--search")
                                .WithCustomHive(_sharedHome.HomeDirectory)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOutContaining("Searching for the templates...")
            .And.HaveStdOutContaining("Matches from template source: NuGet.org")
            .And.HaveStdOutMatching("Template Name\\s+Short Name\\s+Author\\s+Language\\s+Package\\s+Downloads")
            .And.HaveStdOutContaining("To use the template, run the following command to install the package: dotnet new3 -i <package>");

            var tableOutput = ParseTableOutput(commandResult.StdOut, expectedColumns: new[] { "Template Name", "Short Name", "Author", "Language", "Package", "Downloads" });

            Assert.True(AllRowsContain(tableOutput, new[] { "Template Name", "Short Name" }, "azure"), "'Template Name' or 'Short Name' columns do not contain the criteria");

            var microsoftPackages    = tableOutput.Where(row => row[2] == "Microsoft");
            var installationCommands = microsoftPackages.Select(package => $"dotnet new3 -i {package[4]}");

            Func <string, bool> containsOneOfInstallationCommands = (output) => installationCommands.Any(command => output.Contains(command));

            commandResult.Should().HaveStdOutContaining(containsOneOfInstallationCommands, "Checks if the output contains one of the expected installation commands");
        }
示例#4
0
        public void ErrorExitCodeOnFailedPostAction(string templateLocation, string templateName, bool errorExpected)
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate(templateLocation, _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, templateName)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            if (errorExpected)
            {
                commandResult.Should().Fail();
            }
            else
            {
                commandResult.Should().Pass();
            }

            commandResult
            .Should()
            .HaveStdOutContaining($"The template \"{templateName}\" was created successfully.")
            .And.HaveStdOutContaining("Processing post-creation actions...")
            .And.HaveStdOutContaining("Restoring")
            .And.NotHaveStdOutContaining("Restore succeeded.")
            .And.HaveStdErrContaining("Post action failed.")
            .And.HaveStdErrContaining("Manual instructions: Run 'dotnet restore'");

            new DotnetCommand(_log, "build", "--no-restore")
            .WithWorkingDirectory(workingDirectory)
            .Execute()
            .Should().Fail();
        }
        private Task MultiValueChoiceParameterConditionsExecutor(string[] args)
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate("TemplateWithMultiValueChoice", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, args)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .Pass()
            .And.NotHaveStdErr()
            .And.HaveStdOutMatching("The template \"TemplateWithMultiValueChoice\" was created successfully\\.");

            string resultFileContent = File.ReadAllText(Path.Combine(workingDirectory, "Test.cs"));

            var settings = new VerifySettings();

            settings.UseDirectory("Approvals");
            settings.DisableRequireUniquePrefix();

            return(Verifier.Verify(resultFileContent, settings));
        }
        public Task CanShowError_OnTemplatesWithSameShortName()
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();
            string templateLocation = Helpers.InstallTestTemplate("Invalid/SameShortName", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "sameshortname")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .Fail()
            .And.NotHaveStdOut();

            return(Verifier.Verify(commandResult.StdErr, _verifySettings)
                   .AddScrubber(output =>
            {
                //removes the delimiter line as we don't know the length of last columns containing paths above
                output.ScrubTableHeaderDelimiter();
                //removes the spaces after "Package" column header as we don't know the amount of spaces after it (depends on the paths above)
                output.ScrubByRegex("Package *", "Package");
                output = output.Replace(templateLocation, "%TEMPLATE LOCATION%");
            }));
        }
        public Task CannotInstantiateTemplate_WhenAmbiguousShortNameChoice()
        {
            string home                = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory    = TestUtils.CreateTemporaryFolder();
            string templateOneLocation = Helpers.InstallTestTemplate("TemplateResolution/SameShortName/BasicFSharp", _log, home, workingDirectory);
            string templateTwoLocation = Helpers.InstallTestTemplate("TemplateResolution/SameShortName/BasicVB", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "basic")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .Fail()
            .And.NotHaveStdOut();

            return(Verifier.Verify(commandResult.StdErr, _verifySettings)
                   .AddScrubber(output =>
            {
                //package locaions are machine specific so we cannot use them in approval tests
                output.Replace(templateOneLocation, "%TEMPLATE ONE LOCATION%");
                output.Replace(templateTwoLocation, "%TEMPLATE TWO LOCATION%");

                //removes the delimiter line as we don't know the length of last columns containing paths above
                output.ScrubTableHeaderDelimiter();
                //removes the spaces after "Package" column header as we don't know the amount of spaces after it (depends on the paths above)
                output.ScrubByRegex("Package *", "Package");
            }));
        }
示例#8
0
        public Task Restore_Basic_Approval()
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate("PostActions/RestoreNuGet/Basic", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "TestAssets.PostActions.RestoreNuGet.Basic", "-n", "MyProject")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .UniqueForOSPlatform()
                   .ScrubInlineGuids()
                   .AddScrubber(output =>
            {
                //for OSX Verify.NET is not replacing temporary path correctly.
                output.Replace("/private{TempPath}", "{TempPath}");
                output.ScrubByRegex("(?<=Restoring {TempPath}TemplateEngine\\.Tests(\\\\|\\/)Guid_1(\\\\|\\/)MyProject.csproj:\\n)(.*?)(?=\\nRestore succeeded)", "%RESTORE CALLBACK OUTPUT%", System.Text.RegularExpressions.RegexOptions.Singleline);
            }));
        }
示例#9
0
        public void CanOverwriteFilesWithForce()
        {
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            var commandResult = new DotnetNewCommand(_log, "console", "--no-restore")
                                .WithCustomHive(_fixture.HomeDirectory)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOutContaining("The template \"Console App\" was created successfully.");

            var forceCommandResult = new DotnetNewCommand(_log, "console", "--no-restore", "--force")
                                     .WithCustomHive(_fixture.HomeDirectory)
                                     .WithWorkingDirectory(workingDirectory)
                                     .Execute();

            forceCommandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOutContaining("The template \"Console App\" was created successfully.");

            Assert.Equal(commandResult.StdOut, forceCommandResult.StdOut);
        }
示例#10
0
        public void TestDotnetCLIEnvVariable(string dotnetCliEnvVar, string expectedName)
        {
            var home                = TestUtils.CreateTemporaryFolder("Home");
            var thisDir             = Path.GetDirectoryName(typeof(DotnetNewLocaleTests).Assembly.Location);
            var testTemplatesFolder = Path.Combine(
                thisDir ?? string.Empty,
                "..",
                "..",
                "..",
                "..",
                "..",
                "test",
                "Microsoft.TemplateEngine.TestTemplates",
                "test_templates",
                "TemplateWithLocalization");

            var commandResult = new DotnetNewCommand(_log, "-i", testTemplatesFolder)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .WithEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", dotnetCliEnvVar)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And
            .NotHaveStdErr()
            .And
            .HaveStdOutMatching(Regex.Escape(expectedName) + ".*TestAssets.TemplateWithLocalization");
        }
        public Task CanShowWarning_WhenHostDataIsIncorrect()
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();
            var    templateLocation = Helpers.InstallTestTemplate("Invalid/InvalidHostData", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "TestAssets.Invalid.InvalidHostData")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .AddScrubber(output =>
            {
                //output contains path to host.json file - it is machine-specific.
                output.Replace($"{templateLocation}{Path.DirectorySeparatorChar}", "%TEMPLATE ROOT%");
                //details varies based on OS
                output.ScrubDetails();
            }));
        }
示例#12
0
        public void CanInstallRemoteNuGetPackage_LatestVariations()
        {
            var command1 = new DotnetNewCommand(_log, "-i", "Microsoft.DotNet.Common.ProjectTemplates.5.0", "--quiet")
                           .WithCustomHive()
                           .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                           .Execute();

            var command2 = new DotnetNewCommand(_log, "-i", "Microsoft.DotNet.Common.ProjectTemplates.5.0::", "--quiet")
                           .WithCustomHive()
                           .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                           .Execute();

            var command3 = new DotnetNewCommand(_log, "-i", "Microsoft.DotNet.Common.ProjectTemplates.5.0::*", "--quiet")
                           .WithCustomHive()
                           .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                           .Execute();

            foreach (var commandResult in new[] { command1, command2, command3 })
            {
                commandResult.Should()
                .ExitWith(0)
                .And
                .NotHaveStdErr()
                .And.NotHaveStdOutContaining("Determining projects to restore...")
                .And.HaveStdOutContaining("The following template packages will be installed:")
                .And.HaveStdOutMatching($"Success: Microsoft\\.DotNet\\.Common\\.ProjectTemplates\\.5\\.0::([\\d\\.a-z-])+ installed the following templates:")
                .And.HaveStdOutContaining("console")
                .And.NotHaveStdOutContaining("web");
            }

            Assert.True(command1.StdOut.Equals(command2.StdOut));
            Assert.True(command1.StdOut.Equals(command3.StdOut));
        }
示例#13
0
        public void TestDefaultLocale()
        {
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

            var home                = TestUtils.CreateTemporaryFolder("Home");
            var thisDir             = Path.GetDirectoryName(typeof(DotnetNewLocaleTests).Assembly.Location);
            var testTemplatesFolder = Path.Combine(
                thisDir ?? string.Empty,
                "..",
                "..",
                "..",
                "..",
                "..",
                "test",
                "Microsoft.TemplateEngine.TestTemplates",
                "test_templates",
                "TemplateWithLocalization");

            var commandResult = new DotnetNewCommand(_log, "-i", testTemplatesFolder)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .WithEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", string.Empty)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And
            .NotHaveStdErr()
            .And
            .HaveStdOutMatching("name.*TestAssets.TemplateWithLocalization");
        }
        public Task DryRunRespectsTargetPathAndOutputDir()
        {
            const string _OUT_FOLDER      = "folderF";
            string       home             = TestUtils.CreateTemporaryFolder("Home");
            string       workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate("TemplateWithSourceNameAndCustomTargetPath", _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "TestAssets.TemplateWithSourceNameAndCustomTargetPath", "-o", _OUT_FOLDER, "--dry-run")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            string[] expectedFiles = new[] { $"{_OUT_FOLDER}.name.txt", $"{_OUT_FOLDER}/{_OUT_FOLDER}.cs" };

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .AddScrubber(output =>
            {
                //unify directory separators
                output = output.Replace("\\", "/");
                //order of files may vary, replace filename with placeholders
                //filenames are verified above
                foreach (var file in expectedFiles)
                {
                    output = output.Replace(file, "%FILENAME%");
                }
            }));
        }
        public void RunScript_Basic()
        {
            string templateLocation = "PostActions/RunScript/Basic";
            string templateName     = "TestAssets.PostActions.RunScript.Basic";
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate(templateLocation, _log, workingDirectory, home);

            var commandResult = new DotnetNewCommand(_log, templateName, "--allow-scripts", "yes")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOutContaining($"The template \"{templateName}\" was created successfully.")
            .And.NotHaveStdOutContaining("Run 'chmod +x *.sh'")
            .And.NotHaveStdOutContaining("Manual instructions: Run 'setup.cmd'")
            .And.NotHaveStdOutContaining("Manual instructions: Run 'setup.sh'");

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                commandResult.Should().HaveStdOutContaining("Hello Windows");
            }
            else
            {
                commandResult.Should().HaveStdOutContaining("Hello Unix");
            }
        }
示例#16
0
        public Task AddPackageReference_Basic_Approval()
        {
            string templateLocation = "PostActions/AddPackageReference/Basic";
            string templateName     = "TestAssets.PostActions.AddPackageReference.Basic";
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate(templateLocation, _log, home, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, templateName, "-n", "MyProject")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .UniqueForOSPlatform()
                   .ScrubInlineGuids()
                   .AddScrubber(output =>
            {
                //for OSX Verify.NET is not replacing temporary path correctly.
                output.Replace("/private{TempPath}", "{TempPath}");
                output.ScrubByRegex("(?<=Adding a package reference Newtonsoft.Json \\(version: 13.0.1\\) to project file {TempPath}TemplateEngine\\.Tests(\\\\|\\/)Guid_1(\\\\|\\/)MyProject.csproj:\\n)(.*?)(?=\\nSuccessfully added a reference to the project file.)", "%CALLBACK OUTPUT%", System.Text.RegularExpressions.RegexOptions.Singleline);
            }));
        }
        public Task CanShowWarningIfPackageIsAvailableFromBuiltInSources()
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            new DotnetNewCommand(_log, "install", "Microsoft.DotNet.Common.ItemTemplates::6.0.100", "--force")
            .WithCustomHive(home)
            .WithWorkingDirectory(workingDirectory)
            .Execute()
            .Should().Pass();

            var commandResult = new DotnetNewCommand(_log, "gitignore")
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .AddScrubber(output =>
            {
                output.ScrubByRegex("'Microsoft\\.DotNet\\.Common\\.ItemTemplates::[A-Za-z0-9.-]+' is available in", "'Microsoft.DotNet.Common.ItemTemplates::%VERSION%' is available in");
                output.ScrubByRegex("install Microsoft\\.DotNet\\.Common\\.ItemTemplates::[A-Za-z0-9.-]+", "install Microsoft.DotNet.Common.ItemTemplates::%VERSION%");
            }));
        }
示例#18
0
        public Task CannotShowHelpForTemplate_PartialNameMatch()
        {
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            var commandResult = new DotnetNewCommand(_log, "class", "-h")
                                .WithCustomHive(_fixture.HomeDirectory)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult.Should().Pass().And.NotHaveStdErr();
            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }
示例#19
0
        public void CanDisableBuiltInTemplates_Template()
        {
            string homeDir       = TestUtils.CreateTemporaryFolder();
            var    commandResult = new DotnetNewCommand(_log, "console", "--debug:disable-sdk-templates")
                                   .WithCustomHive()
                                   .Execute();

            commandResult
            .Should()
            .Fail()
            .And.HaveStdErrContaining("No templates found matching: 'console'.");
        }
示例#20
0
        public void CanFallbackToListOption(string command1, string command2)
        {
            var commandResult1 = new DotnetNewCommand(_log, command1.Split())
                                 .WithCustomHive(_sharedHome.HomeDirectory)
                                 .Execute();

            var commandResult2 = new DotnetNewCommand(_log, command2.Split())
                                 .WithCustomHive(_sharedHome.HomeDirectory)
                                 .Execute();

            Assert.Equal(commandResult1.StdOut, commandResult2.StdOut);
        }
示例#21
0
        public void CanDisableBuiltInTemplates_List()
        {
            string homeDir       = TestUtils.CreateTemporaryFolder();
            var    commandResult = new DotnetNewCommand(_log, "list", "--debug:disable-sdk-templates")
                                   .WithCustomHive()
                                   .Execute();

            commandResult
            .Should()
            .Pass()
            .And.NotHaveStdOutContaining("console")
            .And.HaveStdOutContaining("No templates installed.");
        }
示例#22
0
        public Task DoNotShowDeprecationMessage_WhenNewCommandIsUsed()
        {
            var commandResult = new DotnetNewCommand(_log, "list")
                                .WithCustomHive()
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .Execute();

            commandResult
            .Should()
            .Pass();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }
#pragma warning restore xUnit1004 // Test methods should not be skipped
        public void CanDoTabCompletionAtGivenPosition()
        {
            string homeDir       = TestUtils.CreateTemporaryFolder();
            var    commandResult = new DotnetNewCommand(_log, "complete", $"new3 co --debug:custom-hive {homeDir} --language C#", "--position", "7")
                                   .WithoutCustomHive()
                                   .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.HaveStdOut("console");
        }
示例#24
0
        public void DoNotShowDeprecationMessage_WhenNewCommandIsUsed()
        {
            var home          = TestUtils.CreateTemporaryFolder("Home");
            var commandResult = new DotnetNewCommand(_log, "update")
                                .WithCustomHive(home)
                                .Execute();

            commandResult.Should()
            .ExitWith(0)
            .And.NotHaveStdErr()
            .And.NotHaveStdOutContaining("Warning")
            .And.NotHaveStdOutContaining("deprecated");
        }
示例#25
0
        public Task CannotShowHelpForTemplate_MatchOnNonChoiceParamWithoutValue()
        {
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            var commandResult = new DotnetNewCommand(_log, "console", "--help", "--langVersion")
                                .WithCustomHive(_fixture.HomeDirectory)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            //help command cannot fail, therefore the output is written to stdout
            commandResult.Should().Pass().And.NotHaveStdErr();
            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }
        public Task CanDoTabCompletion()
        {
            string homeDir       = TestUtils.CreateTemporaryFolder();
            var    commandResult = new DotnetNewCommand(_log, "complete", $"new3 --debug:custom-hive {homeDir} ")
                                   .WithoutCustomHive()
                                   .Execute();

            commandResult
            .Should()
            .ExitWith(0)
            .And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }
        public Task CannotInstantiateTemplateWithUnknownType()
        {
            var commandResult = new DotnetNewCommand(_log, "console", "--type", "item")
                                .WithCustomHive(_fixture.HomeDirectory)
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .Execute();

            commandResult
            .Should()
            .Fail()
            .And.NotHaveStdOut();

            return(Verifier.Verify(commandResult.StdErr, _verifySettings));
        }
示例#28
0
        public Task CanShowDeprecationMessage_WhenLegacyCommandIsUsed(string commandName)
        {
            var commandResult = new DotnetNewCommand(_log, commandName)
                                .WithCustomHive()
                                .WithWorkingDirectory(TestUtils.CreateTemporaryFolder())
                                .Execute();

            commandResult
            .Should()
            .Pass();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings)
                   .UseTextForParameters("common")
                   .DisableRequireUniquePrefix());
        }
示例#29
0
        public Task CanShowHelpForTemplate_MultipleValueChoice()
        {
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            Helpers.InstallTestTemplate("TemplateWithMultiValueChoice", _log, _fixture.HomeDirectory, workingDirectory);

            var commandResult = new DotnetNewCommand(_log, "TestAssets.TemplateWithMultiValueChoice", "--help")
                                .WithCustomHive(_fixture.HomeDirectory)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            //help command should not fail, therefore the output is written to stdout
            commandResult.Should().Pass().And.NotHaveStdErr();
            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }
示例#30
0
        public Task CanShowBasicInfo()
        {
            string home             = TestUtils.CreateTemporaryFolder("Home");
            string workingDirectory = TestUtils.CreateTemporaryFolder();

            var commandResult = new DotnetNewCommand(_log)
                                .WithCustomHive(home)
                                .WithWorkingDirectory(workingDirectory)
                                .Execute();

            commandResult.Should()
            .ExitWith(0).And.NotHaveStdErr();

            return(Verifier.Verify(commandResult.StdOut, _verifySettings));
        }