src/Microsoft.VisualStudio.Editor.UnitTests/MyExtensibility/MyExtensibilitySettingsTest.cs
/// <summary>
/// Project mock returns 5 Templates triggerred by the same assembly, 1 without version, 2 with version 1,
/// 2 with version 2. Verify that we can get the extension template back with different assembly version.
/// </summary>
Project mock returns 5 Templates triggerred by the same assembly, 1 without version, 2 with version 1,
2 with version 2. Verify that we can get the extension template back with different assembly version.
Project mock returns 5 Templates triggerred by the same assembly 1 without version 2 with version 1 2 with version 2 . Verify that we can get the extension template back with different assembly version .
[TestMethod()]
        public void MyExtSettingsGetExtensionTemplateMixAssemblyVersion()
        {
            MyExtensibilitySettings extSettings = new MyExtensibilitySettings("NotExistedPath");
            Mock<Project> projectMock = CreateProjectMock(PROJECTKIND_VB, CUSTOMDATASIGNATURE_VB, 
                new Mock<Template>[] { 
                    Util.CreateTemplateMockSample4(),
                    Util.CreateTemplateMockSample5(), 
                    Util.CreateTemplateMockSample6(), 
                    Util.CreateTemplateMockSample7(), 
                    Util.CreateTemplateMockSample8()});
            List<MyExtensionTemplate> extensionTemplates1 = extSettings.GetExtensionTemplates(PROJECTKIND_VB, projectMock.Instance, Util.ASMNAME_ASMWTVER_1);
            Assert.IsTrue(null != extensionTemplates1 && 3 == extensionTemplates1.Count, "Could not find extension template for " + Util.ASMNAME_ASMWTVER_1);
            List<string> extensionIDs1 = new List<string>();
            extensionIDs1.Add("Company.Product.AssemblyWithoutVersion.MyExtension");
            extensionIDs1.Add("Company.Product.AssemblyWithoutVersion.MyExtension11");
            extensionIDs1.Add("Company.Product.AssemblyWithoutVersion.MyExtension12");
            foreach (MyExtensionTemplate extensionTemplate in extensionTemplates1)
            { 
                if (extensionIDs1.Contains(extensionTemplate.ID))
                {
                    extensionIDs1.Remove(extensionTemplate.ID);
                }
            }
            Assert.IsTrue(0 == extensionIDs1.Count, "First set of extension IDs do not match.");
            List<MyExtensionTemplate> extensionTemplates2 = extSettings.GetExtensionTemplates(PROJECTKIND_VB, projectMock.Instance, Util.ASMNAME_ASMWTVER_2);
            Assert.IsTrue(null != extensionTemplates2 && 3 == extensionTemplates2.Count, "Could not find extension template for " + Util.ASMNAME_ASMWTVER_2);
            List<string> extensionIDs2 = new List<string>();
            extensionIDs2.Add("Company.Product.AssemblyWithoutVersion.MyExtension");
            extensionIDs2.Add("Company.Product.AssemblyWithoutVersion.MyExtension21");
            extensionIDs2.Add("Company.Product.AssemblyWithoutVersion.MyExtension22");
            foreach (MyExtensionTemplate extensionTemplate in extensionTemplates2)
            {
                if (extensionIDs2.Contains(extensionTemplate.ID))
                {
                    extensionIDs2.Remove(extensionTemplate.ID);
                }
            }
            Assert.IsTrue(0 == extensionIDs2.Count, "Second set of extension IDs do not match.");
        }
[ TestMethod ( ) ] public void MyExtSettingsGetExtensionTemplateMixAssemblyVersion ( ) { MyExtensibilitySettings extSettings = new MyExtensibilitySettings ( " " ) ; Mock < Project > projectMock = CreateProjectMock ( PROJECTKIND_VB , CUSTOMDATASIGNATURE_VB , new Mock < Template > [ ] { Util . CreateTemplateMockSample4 ( ) , Util . CreateTemplateMockSample5 ( ) , Util . CreateTemplateMockSample6 ( ) , Util . CreateTemplateMockSample7 ( ) , Util . CreateTemplateMockSample8 ( ) } ) ; List < MyExtensionTemplate > extensionTemplates1 = extSettings . GetExtensionTemplates ( PROJECTKIND_VB , projectMock . Instance , Util . ASMNAME_ASMWTVER_1 ) ; Assert . IsTrue ( null != extensionTemplates1 && 3 == extensionTemplates1 . Count , " " + Util . ASMNAME_ASMWTVER_1 ) ; List < string > extensionIDs1 = new List < string > ( ) ; extensionIDs1 . Add ( " " ) ; extensionIDs1 . Add ( " " ) ; extensionIDs1 . Add ( " " ) ; foreach ( MyExtensionTemplate extensionTemplate in extensionTemplates1 ) { if ( extensionIDs1 . Contains ( extensionTemplate . ID ) ) { extensionIDs1 . Remove ( extensionTemplate . ID ) ; } } Assert . IsTrue ( 0 == extensionIDs1 . Count , " " ) ; List < MyExtensionTemplate > extensionTemplates2 = extSettings . GetExtensionTemplates ( PROJECTKIND_VB , projectMock . Instance , Util . ASMNAME_ASMWTVER_2 ) ; Assert . IsTrue ( null != extensionTemplates2 && 3 == extensionTemplates2 . Count , " " + Util . ASMNAME_ASMWTVER_2 ) ; List < string > extensionIDs2 = new List < string > ( ) ; extensionIDs2 . Add ( " " ) ; extensionIDs2 . Add ( " " ) ; extensionIDs2 . Add ( " " ) ; foreach ( MyExtensionTemplate extensionTemplate in extensionTemplates2 ) { if ( extensionIDs2 . Contains ( extensionTemplate . ID ) ) { extensionIDs2 . Remove ( extensionTemplate . ID ) ; } } Assert . IsTrue ( 0 == extensionIDs2 . Count , " " ) ; }
Project mock returns 5 Templates triggerred by the same assembly, 1 without version, 2 with version 1,
2 with version 2.
Project mock returns 5 Templates triggerred by the same assembly 1 without version 2 with version 1 2 with version 2 .