Example #1
0
        public void GetParametersInvalidForTemplatesInList_NoneForAllTest()
        {
            List <ITemplateMatchInfo> matchInfo = new List <ITemplateMatchInfo>();

            // template one
            List <MatchInfo> templateOneDispositions = new List <MatchInfo>();

            templateOneDispositions.Add(new MatchInfo()
            {
                Location = MatchLocation.OtherParameter, Kind = MatchKind.InvalidParameterName, InputParameterName = "foo"
            });
            templateOneDispositions.Add(new MatchInfo()
            {
                Location = MatchLocation.OtherParameter, Kind = MatchKind.InvalidParameterName, InputParameterName = "bar"
            });
            ITemplateMatchInfo templateOneMatchInfo = new TemplateMatchInfo(new TemplateInfo(), templateOneDispositions);

            matchInfo.Add(templateOneMatchInfo);

            // template two
            List <MatchInfo>   templateTwoDispositions = new List <MatchInfo>();
            ITemplateMatchInfo templateTwoMatchInfo    = new TemplateMatchInfo(new TemplateInfo(), templateTwoDispositions);

            matchInfo.Add(templateTwoMatchInfo);

            HelpForTemplateResolution.GetParametersInvalidForTemplatesInList(matchInfo, out IReadOnlyList <string> invalidForAllTemplates, out IReadOnlyList <string> invalidForSomeTemplates);

            Assert.Equal(0, invalidForAllTemplates.Count);

            Assert.Equal(2, invalidForSomeTemplates.Count);
            Assert.Contains("foo", invalidForSomeTemplates);
            Assert.Contains("bar", invalidForSomeTemplates);
        }
Example #2
0
        public void GetParametersInvalidForTemplatesInList_NoneForSomeTest()
        {
            List <ITemplateMatchInfo> matchInfo = new List <ITemplateMatchInfo>();

            // template one
            List <MatchInfo> templateOneDispositions = new List <MatchInfo>();

            templateOneDispositions.Add(new ParameterMatchInfo("foo", "test", MatchKind.InvalidName));
            ITemplateMatchInfo templateOneMatchInfo = new TemplateMatchInfo(new MockTemplateInfo(), templateOneDispositions);

            matchInfo.Add(templateOneMatchInfo);

            // template two
            List <MatchInfo> templateTwoDispositions = new List <MatchInfo>();

            templateTwoDispositions.Add(new ParameterMatchInfo("foo", "test", MatchKind.InvalidName));
            ITemplateMatchInfo templateTwoMatchInfo = new TemplateMatchInfo(new MockTemplateInfo(), templateTwoDispositions);

            matchInfo.Add(templateTwoMatchInfo);

            HelpForTemplateResolution.GetParametersInvalidForTemplatesInList(matchInfo, out IReadOnlyList <string> invalidForAllTemplates, out IReadOnlyList <string> invalidForSomeTemplates);

            Assert.Equal(1, invalidForAllTemplates.Count);
            Assert.Contains("foo", invalidForAllTemplates);

            Assert.Equal(0, invalidForSomeTemplates.Count);
        }
        public void TestGetTemplateResolutionResult_OtherParameterMatch_Text()
        {
            List <ITemplateInfo> templatesToSearch = new List <ITemplateInfo>();

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

            templatesToSearch.Add(
                new MockTemplateInfo("console", name: "Long name for Console App", identity: "Console.App.T2", groupIdentity: "Console.App.Test2")
                .WithTag("language", "L2")
                .WithTag("type", "project")
                .WithParameters("test")
                .WithBaselineInfo("app", "standard"));

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

            INewCommandInput userInputs = new MockNewCommandInput("c").WithHelpOption().WithTemplateOption("langVersion");

            TemplateListResolutionResult matchResult = TemplateResolver.GetTemplateResolutionResultForListOrHelp(templatesToSearch, new MockHostSpecificDataLoader(), userInputs, null);

            Assert.True(matchResult.HasExactMatches);
            Assert.Equal(1, matchResult.ExactMatchedTemplateGroups.Count);
            Assert.Equal(1, matchResult.ExactMatchedTemplates.Count);
            Assert.False(matchResult.HasLanguageMismatch);
            Assert.False(matchResult.HasContextMismatch);
            Assert.False(matchResult.HasBaselineMismatch);
            Assert.True(matchResult.HasUnambiguousTemplateGroup);
            Assert.Equal(1, matchResult.UnambiguousTemplateGroup.Count);
            HelpForTemplateResolution.GetParametersInvalidForTemplatesInList(matchResult.ExactMatchedTemplates, out IReadOnlyList <string> invalidForAllTemplates, out IReadOnlyList <string> invalidForSomeTemplates);
            Assert.Equal(0, invalidForSomeTemplates.Count);
            Assert.Equal(0, invalidForAllTemplates.Count);
        }