src/Microsoft.VisualStudio.Editor.UnitTests/MyExtensibility/MyExtensibilitySettingsTest.cs
/// <summary>
/// GetExtensionTemplates with assembly name should only return the latest version of the template.
/// </summary>
GetExtensionTemplates with assembly name should only return the latest version of the template.
GetExtensionTemplates with assembly name should only return the latest version of the template .
[TestMethod()]
        public void MyExtSettingsGetExtensionTemplatesBasedOnTemplateVersion02()
        {
            MyExtensibilitySettings extSettings = new MyExtensibilitySettings("NotExistedPath");
            string id = "My.BasedOnTemplateVersion01";
            Mock<Template> templateMock1 = Util.CreateTemplateMock("MyTemplateVersion1", id, "1", "System.Drawing");
            Mock<Template> templateMock2 = Util.CreateTemplateMock("MyTemplateVersion1.0", id, "1.0", "System.Drawing");
            Mock<Template> templateMock3 = Util.CreateTemplateMock("MyTemplateVersion1.5", id, "1.5", "System.Drawing, Version=1.0.0.0");
            Mock<Template> templateMock4 = Util.CreateTemplateMock("MyTemplateVersion1.5.0", id, "1.5.0", "System.Drawing, Version=1.0.0.0");
            Mock<Template> templateMock5 = Util.CreateTemplateMock("MyTemplateVersion1.5.0.6", id, "1.5.0.6", "System.Drawing, Version=2.0.0.0");
            Mock<Template> templateMock6 = Util.CreateTemplateMock("MyTemplateVersion1.5.0.7", id, "1.5.0.7", "System.Drawing, Version=2.0.0.0");
            Mock<Project> projectMock = CreateProjectMock(PROJECTKIND_VB, CUSTOMDATASIGNATURE_VB,
                new Mock<Template>[] { templateMock1, templateMock2, templateMock3, templateMock4, templateMock5, templateMock6 });
            List<MyExtensionTemplate> extTemplates = extSettings.GetExtensionTemplates(
                PROJECTKIND_VB, projectMock.Instance, "System.Drawing, Version=2.0.0.0");
            if (null == extTemplates)
            {
                Assert.Fail("Expect 1 extension. Got NULL.");
            }
            else
            {
                Assert.IsTrue(1 == extTemplates.Count, string.Format("Expect 1 extension. Got {0}.", extTemplates.Count));
                MyExtensionTemplate extTemplate = extTemplates[0];
                Assert.IsTrue(extTemplate.Version.Equals(new Version(1, 5, 0, 7)),
                    string.Format("Expect version 1.5.0.7. Got {0}.", extTemplate.Version.ToString()));
            }
        }
[ TestMethod ( ) ] public void MyExtSettingsGetExtensionTemplatesBasedOnTemplateVersion02 ( ) { MyExtensibilitySettings extSettings = new MyExtensibilitySettings ( " " ) ; string id = " " ; Mock < Template > templateMock1 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Template > templateMock2 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Template > templateMock3 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Template > templateMock4 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Template > templateMock5 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Template > templateMock6 = Util . CreateTemplateMock ( " " , id , " " , " " ) ; Mock < Project > projectMock = CreateProjectMock ( PROJECTKIND_VB , CUSTOMDATASIGNATURE_VB , new Mock < Template > [ ] { templateMock1 , templateMock2 , templateMock3 , templateMock4 , templateMock5 , templateMock6 } ) ; List < MyExtensionTemplate > extTemplates = extSettings . GetExtensionTemplates ( PROJECTKIND_VB , projectMock . Instance , " " ) ; if ( null == extTemplates ) { Assert . Fail ( " " ) ; } else { Assert . IsTrue ( 1 == extTemplates . Count , string . Format ( " " , extTemplates . Count ) ) ; MyExtensionTemplate extTemplate = extTemplates [ 0 ] ; Assert . IsTrue ( extTemplate . Version . Equals ( new Version ( 1 , 5 , 0 , 7 ) ) , string . Format ( " " , extTemplate . Version . ToString ( ) ) ) ; } }
GetExtensionTemplates with assembly name should only return the latest version of the template.
GetExtensionTemplates with assembly name should only return the latest version of the template .