Ejemplo n.º 1
0
        public async Task CacheSearchPackageFilterTest(string commandTemplate, string commandPackage, int packMatchCount, int templateMatchCount)
        {
            string cacheLocation  = TestUtils.CreateTemporaryFolder();
            string v1FileLocation = SetupDiscoveryMetadata(cacheLocation, false);
            string v2FileLocation = SetupTemplateCache(cacheLocation, false);

            var environment = A.Fake <IEnvironment>();
            var engineEnvironmentSettings = _environmentSettingsHelper.CreateEnvironment(
                virtualize: true,
                environment: environment,
                additionalComponents: BuiltInTemplatePackagesProviderFactory.GetComponents(includeTestTemplates: false));
            var templatePackageManager = new TemplatePackageManager(engineEnvironmentSettings);

            engineEnvironmentSettings.Components.AddComponent(typeof(ITemplateSearchProviderFactory), new NuGetMetadataSearchProviderFactory());

            NewCommand        myCommand   = (NewCommand)NewCommandFactory.Create("new", _ => engineEnvironmentSettings.Host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var               parseResult = myCommand.Parse($"new search {commandTemplate} --package {commandPackage}");
            SearchCommandArgs args        = new SearchCommandArgs((SearchCommand)parseResult.CommandResult.Command, parseResult);

            var templatePackages = await templatePackageManager.GetManagedTemplatePackagesAsync(false, default).ConfigureAwait(false);

            TemplateSearchCoordinator searchCoordinator = CliTemplateSearchCoordinatorFactory.CreateCliTemplateSearchCoordinator(engineEnvironmentSettings);
            CliSearchFiltersFactory   factory           = new CliSearchFiltersFactory(templatePackages);

            foreach (var location in new[] { v1FileLocation, v2FileLocation })
            {
                A.CallTo(() => environment.GetEnvironmentVariable("DOTNET_NEW_SEARCH_FILE_OVERRIDE")).Returns(location);
                var searchResults = await searchCoordinator.SearchAsync(
                    factory.GetPackFilter(args),
                    CliSearchFiltersFactory.GetMatchingTemplatesFilter(args),
                    default).ConfigureAwait(false);

                Assert.Equal(1, searchResults.Count);
                Assert.Single(searchResults, result => result.Provider.Factory.DisplayName == "NuGet.org");
                var nugetSearchResults = searchResults.Single(result => result.Provider.Factory.DisplayName == "NuGet.org");
                Assert.Equal(packMatchCount, nugetSearchResults.SearchHits.Count);
                if (packMatchCount != 0)
                {
                    Assert.Equal(templateMatchCount, nugetSearchResults.SearchHits.Single(res => res.PackageInfo.Name == _packThreeInfo.Name).MatchedTemplates.Count);
                }
            }
        }
Ejemplo n.º 2
0
        public void DebugFlagCanBeParsedOnTemplateSubcommandLevel(string command, string option)
        {
            Dictionary <string, Func <GlobalArgs, bool> > optionsMap = new Dictionary <string, Func <GlobalArgs, bool> >()
            {
                { "--debug:attach", args => args.DebugAttach },
                { "--debug:ephemeral-hive", args => args.DebugVirtualizeSettings },
                { "--debug:reinit", args => args.DebugReinit },
                { "--debug:rebuild-cache", args => args.DebugRebuildCache },
                { "--debug:show-config", args => args.DebugShowConfig }
            };

            ITemplateEngineHost host      = TestHost.GetVirtualHost(additionalComponents: BuiltInTemplatePackagesProviderFactory.GetComponents(includeTestTemplates: false));
            NewCommand          myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var parseResult             = myCommand.Parse(command);
            InstantiateCommandArgs args = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));

            Assert.True(optionsMap[option](args));
            Assert.Equal("console", args.ShortName);
            Assert.Equal(new[] { "--framework", "net5.0", "--flag" }, args.RemainingArguments);
        }
Ejemplo n.º 3
0
        public Task CanShowHintsForOtherTemplates()
        {
            var template1 = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group").WithTag("language", "Lang1").WithTag("type", "project");
            var template2 = new MockTemplateInfo("foo", identity: "foo.2", groupIdentity: "foo.group").WithTag("language", "Lang2").WithTag("type", "item");

            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template1, template2 }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost host = TestHost.GetVirtualHost();

            NewCommand             myCommand   = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            ParseResult            parseResult = myCommand.Parse("new -h");
            InstantiateCommandArgs args        = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));

            StringWriter sw = new StringWriter();

            InstantiateCommand.ShowHintForOtherTemplates(templateGroup, templateGroup.Templates[0], args, sw);
            return(Verifier.Verify(sw.ToString(), _verifySettings.Settings));
        }
Ejemplo n.º 4
0
        public Task CanShowCommandOptions_Basic()
        {
            var           template      = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group");
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            TemplateCommand templateCommand = new TemplateCommand(myCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());

            StringWriter sw          = new StringWriter();
            HelpContext  helpContext = new HelpContext(new HelpBuilder(LocalizationResources.Instance), myCommand, sw);

            InstantiateCommand.ShowCommandOptions(new[] { templateCommand }, templateCommand, helpContext);
            return(Verifier.Verify(sw.ToString(), _verifySettings.Settings));
        }
Ejemplo n.º 5
0
        public void CanShowCommandOptions_NoOptions()
        {
            var           template      = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group").WithTag("type", "MyType");
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            TemplateCommand templateCommand = new TemplateCommand(myCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());

            StringWriter sw          = new StringWriter();
            HelpContext  helpContext = new HelpContext(new HelpBuilder(LocalizationResources.Instance), myCommand, sw);

            InstantiateCommand.ShowTemplateSpecificOptions(new[] { templateCommand }, helpContext);
            Assert.Equal($"Template options:{Environment.NewLine}   (No options){Environment.NewLine}", sw.ToString());
        }
Ejemplo n.º 6
0
        internal void Create_CanEvaluateTemplateWithSubcommandShortName(string command, string?expectedIdentitiesStr)
        {
            MockTemplateInfo template = new MockTemplateInfo(command, identity: $"{command}Template");

            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            string[]                   expectedIdentities = expectedIdentitiesStr?.Split("|") ?? Array.Empty <string>();
            ITemplateEngineHost        host     = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings = new EngineEnvironmentSettings(host, virtualizeSettings: true);

            NewCommand myCommand          = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var        parseResult        = myCommand.Parse($"new create {command}");
            var        instantiateCommand = (InstantiateCommand)parseResult.CommandResult.Command;
            var        args             = new InstantiateCommandArgs(instantiateCommand, parseResult);
            var        templateCommands = InstantiateCommand.GetTemplateCommand(args, settings, A.Fake <TemplatePackageManager>(), templateGroup);

            Assert.Equal(expectedIdentities.Count(), templateCommands.Count);
            Assert.Equal(expectedIdentities.OrderBy(s => s), templateCommands.Select(templateCommand => templateCommand.Template.Identity).OrderBy(s => s));
        }
Ejemplo n.º 7
0
        public void AllTemplatesInGroupUseAllShortNamesForResolution(string shortName)
        {
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(_testSets["MultiShortNameGroup"], A.Fake <IHostSpecificDataLoader>()))
                                          .Single();
            var defaultParams = new Dictionary <string, string>()
            {
                { "prefs:language", "C#" }
            };

            ITemplateEngineHost        host     = TestHost.GetVirtualHost(defaultParameters: defaultParams);
            IEngineEnvironmentSettings settings = new EngineEnvironmentSettings(host, virtualizeSettings: true);

            NewCommand             myCommand        = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var                    parseResult      = myCommand.Parse($"new {shortName}");
            InstantiateCommandArgs args             = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            var                    templateCommands = InstantiateCommand.GetTemplateCommand(args, settings, A.Fake <TemplatePackageManager>(), templateGroup);

            Assert.Equal(1, templateCommands.Count);
            Assert.Equal("MultiName.Test.High.CSharp", templateCommands.Single().Template.Identity);
        }
Ejemplo n.º 8
0
#pragma warning restore xUnit1004 // Test methods should not be skipped
        public void CanCompleteParameters_StartsWith_AfterOption()
        {
            var template1 = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
                            .WithChoiceParameter("testChoice", "val1")
                            .WithParameters("foo", "bar");

            var template2 = new MockTemplateInfo("foo", identity: "foo.2", groupIdentity: "foo.group")
                            .WithChoiceParameter("testChoice", "val2", "val3")
                            .WithParameters("test");

            var templateGroups = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template1, template2 }, A.Fake <IHostSpecificDataLoader>()));

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand             myCommand         = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var                    parseResult       = myCommand.Parse($" new foo --foo val1 --bar val2 --t");
            InstantiateCommandArgs args              = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            var                    completionContext = parseResult.GetCompletionContext() as TextCompletionContext;

            Assert.NotNull(completionContext);

            var result = InstantiateCommand.GetTemplateCompletions(args, templateGroups, settings, packageManager, completionContext !).Select(l => l.Label);

            Assert.DoesNotContain("--test", result);
            Assert.Contains("--testChoice", result);
            Assert.DoesNotContain("--foo", result);
            Assert.DoesNotContain("--bar", result);

            Assert.DoesNotContain("-p", result);
            Assert.DoesNotContain("-t", result);
            Assert.DoesNotContain("-f", result);
            Assert.DoesNotContain("-b", result);

            Assert.DoesNotContain("--language", result);
            Assert.DoesNotContain("--type", result);
            Assert.DoesNotContain("--baseline", result);
        }
Ejemplo n.º 9
0
        public void HasMultipleMismatches()
        {
            List <ITemplateInfo> templatesToSearch = new List <ITemplateInfo>();

            templatesToSearch.Add(
                new MockTemplateInfo("console", name: "Long name for Console App", identity: "Console.App.T1", groupIdentity: "Console.App.Test")
                .WithTag("language", "L1")
                .WithTag("type", "project")
                .WithBaselineInfo("app", "standard"));

            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(CliTemplateInfo.FromTemplateInfo(templatesToSearch, A.Fake <IHostSpecificDataLoader>())).Single();

            ITemplateEngineHost        host     = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings = new EngineEnvironmentSettings(host, virtualizeSettings: true);

            NewCommand myCommand         = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var        parseResult       = myCommand.Parse($"new console --language L2 --type item --baseline core");
            var        args              = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            var        matchingTemplates = InstantiateCommand.GetMatchingTemplates(args, settings, A.Fake <TemplatePackageManager>(), templateGroup);

            Assert.Equal(0, matchingTemplates.Count());
        }
Ejemplo n.º 10
0
        public Task CanShowTemplateOptions_SingleTemplate_Choice_ShortenedUsage()
        {
            var template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
                           .WithChoiceParameter("choice", new[] { "val1", "val2", "val3", "val4", "val5", "val6" }, description: "my description", defaultValue: "def-val", defaultIfNoOptionValue: "def-val-no-arg");
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            TemplateCommand templateCommand = new TemplateCommand(myCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());

            StringWriter sw          = new StringWriter();
            HelpContext  helpContext = new HelpContext(new HelpBuilder(LocalizationResources.Instance, maxWidth: 50), myCommand, sw);

            InstantiateCommand.ShowTemplateSpecificOptions(new[] { templateCommand }, helpContext);
            return(Verifier.Verify(sw.ToString(), _verifySettings.Settings));
        }
Ejemplo n.º 11
0
        public void CanShowTemplateOptions_RequiredIsNotShownWhenDefaultValueIsGiven()
        {
            var template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
                           .WithChoiceParameter("choice", new[] { "val1", "val2" }, description: "my description", defaultValue: "def-val", defaultIfNoOptionValue: "def-val-no-arg", isRequired: true);
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            TemplateCommand templateCommand = new TemplateCommand(myCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());

            StringWriter sw          = new StringWriter();
            HelpContext  helpContext = new HelpContext(new HelpBuilder(LocalizationResources.Instance), myCommand, sw);

            InstantiateCommand.ShowTemplateSpecificOptions(new[] { templateCommand }, helpContext);
            Assert.DoesNotContain("(REQUIRED)", sw.ToString());
        }
Ejemplo n.º 12
0
        internal void CanParseNameOption(string command, string?expectedValue)
        {
            var template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group");

            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand             myCommand           = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var                    parseResult         = myCommand.Parse($"new {command}");
            InstantiateCommandArgs args                = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            TemplateCommand        templateCommand     = new TemplateCommand(myCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());
            Parser                 parser              = ParserFactory.CreateParser(templateCommand);
            ParseResult            templateParseResult = parser.Parse(args.RemainingArguments ?? Array.Empty <string>());
            var                    templateArgs        = new TemplateCommandArgs(templateCommand, myCommand, templateParseResult);

            Assert.Equal(expectedValue, templateArgs.Name);
        }
Ejemplo n.º 13
0
        internal void Create_CanParseTemplateOptions(string command, string parameterName, string parameterType, string?defaultValue, string?defaultIfNoOptionValue, string?expectedValue)
        {
            //unique case for dotnet new create
            if (command == "foo -in 30")
            {
                command = "foo -i 30"; //for dotnet new create "-i" is not occupied, so we can use it.
            }

            var template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
                           .WithParameter(parameterName, parameterType, defaultValue: defaultValue, defaultIfNoOptionValue: defaultIfNoOptionValue);

            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()))
                                          .Single();

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand      myCommand          = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var             parseResult        = myCommand.Parse($"new create {command}");
            var             instantiateCommand = (InstantiateCommand)parseResult.CommandResult.Command;
            var             args                = new InstantiateCommandArgs(instantiateCommand, parseResult);
            TemplateCommand templateCommand     = new TemplateCommand(instantiateCommand, settings, packageManager, templateGroup, templateGroup.Templates.Single());
            Parser          parser              = ParserFactory.CreateParser(templateCommand);
            ParseResult     templateParseResult = parser.Parse(args.RemainingArguments ?? Array.Empty <string>());
            var             templateArgs        = new TemplateCommandArgs(templateCommand, instantiateCommand, templateParseResult);

            if (string.IsNullOrWhiteSpace(expectedValue))
            {
                Assert.False(templateArgs.TemplateParameters.ContainsKey(parameterName));
            }
            else
            {
                Assert.True(templateArgs.TemplateParameters.ContainsKey(parameterName));
                Assert.Equal(expectedValue, templateArgs.TemplateParameters[parameterName]);
            }
        }
Ejemplo n.º 14
0
        public void UniqueNameMatchesCorrectly()
        {
            IReadOnlyList <ITemplateInfo> templatesToSearch = new List <ITemplateInfo>()
            {
                new MockTemplateInfo("console2", name: "Long name for Console App #2", identity: "Console.App2")
            };
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(CliTemplateInfo.FromTemplateInfo(templatesToSearch, A.Fake <IHostSpecificDataLoader>())).Single();

            ITemplateEngineHost        host     = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings = new EngineEnvironmentSettings(host, virtualizeSettings: true);

            NewCommand myCommand         = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var        parseResult       = myCommand.Parse($" new console2");
            var        args              = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            var        matchingTemplates = InstantiateCommand.GetMatchingTemplates(args, settings, A.Fake <TemplatePackageManager>(), templateGroup);

            Assert.Equal(1, matchingTemplates.Count());
            StringWriter output   = new StringWriter();
            Reporter     reporter = new Reporter(new AnsiConsole(output));

            Assert.True(InstantiateCommand.VerifyMatchingTemplates(settings, matchingTemplates, reporter, out _));
            Assert.Empty(output.ToString());
        }
Ejemplo n.º 15
0
        public void CanCompleteChoice_FromSingleTemplate_StartsWith()
        {
            var template = new MockTemplateInfo("foo", identity: "foo.1", groupIdentity: "foo.group")
                           .WithChoiceParameter("testChoice", "val1", "val2", "boo");

            var templateGroups = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(new[] { template }, A.Fake <IHostSpecificDataLoader>()));

            ITemplateEngineHost        host           = TestHost.GetVirtualHost();
            IEngineEnvironmentSettings settings       = new EngineEnvironmentSettings(host, virtualizeSettings: true);
            TemplatePackageManager     packageManager = A.Fake <TemplatePackageManager>();

            NewCommand myCommand         = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());
            var        parseResult       = myCommand.Parse($" new foo --testChoice v");
            var        completionContext = parseResult.GetCompletionContext() as TextCompletionContext;

            Assert.NotNull(completionContext);
            InstantiateCommandArgs args = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));

            var result = InstantiateCommand.GetTemplateCompletions(args, templateGroups, settings, packageManager, completionContext !).Select(l => l.Label);

            Assert.Equal(new[] { "val1", "val2" }, result);
        }
Ejemplo n.º 16
0
        [InlineData("eee", "OnlyF", "someValue", "Multiname.Test.Only.FSharp")] // uses a short name from a different template in the group
        public void ParameterExistenceDisambiguatesMatchesWithMultipleShortNames(string name, string paramName, string paramValue, string expectedIdentity)
        {
            TemplateGroup templateGroup = TemplateGroup.FromTemplateList(
                CliTemplateInfo.FromTemplateInfo(_testSets["MultiShortNameGroup"], A.Fake <IHostSpecificDataLoader>()))
                                          .Single();
            var defaultParams = new Dictionary <string, string>()
            {
                { "prefs:language", "C#" }
            };

            ITemplateEngineHost        host     = TestHost.GetVirtualHost(defaultParameters: defaultParams);
            IEngineEnvironmentSettings settings = new EngineEnvironmentSettings(host, virtualizeSettings: true);

            NewCommand myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            string command              = $"new {name} --{paramName} {paramValue}";
            var    parseResult          = myCommand.Parse($" new {command}");
            InstantiateCommandArgs args = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));
            var templateCommands        = InstantiateCommand.GetTemplateCommand(args, settings, A.Fake <TemplatePackageManager>(), templateGroup);

            Assert.Equal(1, templateCommands.Count);
            Assert.Equal(expectedIdentity, templateCommands.Single().Template.Identity);
        }