Пример #1
0
        public void AllTemplatesInGroupUseAllShortNamesForResolution()
        {
            IReadOnlyList <string> shortNamesForGroup = new List <string>()
            {
                "aaa", "bbb", "ccc", "ddd", "eee", "fff"
            };
            string defaultLanguage = "C#";

            foreach (string testShortName in shortNamesForGroup)
            {
                INewCommandInput userInputs = new MockNewCommandInput(testShortName);

                TemplateResolutionResult matchResult = TemplateResolver.GetTemplateResolutionResult(MultiShortNameGroupTemplateInfo, new MockHostSpecificDataLoader(), userInputs, defaultLanguage);
                Assert.Equal(TemplateResolutionResult.UnambiguousTemplateGroupStatus.SingleMatch, matchResult.GroupResolutionStatus);
                Assert.Equal(3, matchResult.UnambiguousTemplateGroup.Templates.Count);
                Assert.True(matchResult.UnambiguousTemplateGroup.Templates.All(t => WellKnownSearchFilters.MatchesAllCriteria(t)));

                foreach (ITemplateMatchInfo templateMatchInfo in matchResult.UnambiguousTemplateGroup.Templates)
                {
                    Assert.Equal("MultiName.Test", templateMatchInfo.Info.GroupIdentity);
                    if (templateMatchInfo.Info.GetLanguage().Equals(defaultLanguage, StringComparison.OrdinalIgnoreCase))
                    {
                        //default language match is part of MatchDisposition collection
                        Assert.Equal(2, templateMatchInfo.MatchDisposition.Count);
                    }
                    else
                    {
                        Assert.Equal(1, templateMatchInfo.MatchDisposition.Count);
                    }
                    Assert.True(templateMatchInfo.MatchDisposition[0].Name == MatchInfo.BuiltIn.ShortName && templateMatchInfo.MatchDisposition[0].Kind == MatchKind.Exact);
                }
            }
        }
Пример #2
0
        public void NamePartialMatch_ReportsCorrectly()
        {
            ITemplateInfo      templateInfo      = new MockTemplateInfo();
            ITemplateMatchInfo templateMatchInfo = new TemplateMatchInfo(templateInfo);

            templateMatchInfo.AddMatchDisposition(new MatchInfo(MatchInfo.BuiltIn.Name, "test", MatchKind.Partial));
            Assert.True(WellKnownSearchFilters.MatchesAllCriteria(templateMatchInfo));
            Assert.True(WellKnownSearchFilters.MatchesAtLeastOneCriteria(templateMatchInfo));
        }
Пример #3
0
        public void TypeMismatch_ReportsCorrectly()
        {
            ITemplateInfo      templateInfo      = new MockTemplateInfo();
            ITemplateMatchInfo templateMatchInfo = new TemplateMatchInfo(templateInfo);

            templateMatchInfo.AddMatchDisposition(new MatchInfo(MatchInfo.BuiltIn.Type, "test", MatchKind.Mismatch));
            Assert.False(WellKnownSearchFilters.MatchesAllCriteria(templateMatchInfo));
            Assert.False(WellKnownSearchFilters.MatchesAtLeastOneCriteria(templateMatchInfo));
        }
Пример #4
0
        public void EmptyMatchDisposition_ReportsCorrectly()
        {
            ITemplateInfo      templateInfo      = new MockTemplateInfo();
            ITemplateMatchInfo templateMatchInfo = new TemplateMatchInfo(templateInfo);

            Assert.False(WellKnownSearchFilters.MatchesAllCriteria(templateMatchInfo));
            Assert.False(WellKnownSearchFilters.MatchesAtLeastOneCriteria(templateMatchInfo));
            Assert.Empty(templateMatchInfo.GetInvalidParameterNames());
            Assert.Equal(0, templateMatchInfo.GetValidTemplateParameters().Count);
        }
Пример #5
0
        public void TypeMatch_ReportsCorrectly()
        {
            ITemplateInfo      templateInfo      = new MockTemplateInfo();
            ITemplateMatchInfo templateMatchInfo = new TemplateMatchInfo(templateInfo);

            templateMatchInfo.AddMatchDisposition(new MatchInfo(MatchInfo.BuiltIn.Type, "test", MatchKind.Exact));
            Assert.True(WellKnownSearchFilters.MatchesAllCriteria(templateMatchInfo));
            Assert.True(WellKnownSearchFilters.MatchesAtLeastOneCriteria(templateMatchInfo));
            Assert.True(templateMatchInfo.IsInvokableMatch());
            Assert.False(templateMatchInfo.HasAmbiguousParameterValueMatch());
        }