コード例 #1
0
        static void TestSetCurrentValue(ResXFileType resXFileType, bool allowNoCodeGeneration, CodeDomProvider codeProvider, string initialCustomTool, string initialNamespace, string newCurrentValue, string expectedCustomTool, string expectedNamespace)
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();
            ProjectItemFake            projectItem;

            projectItem = new ProjectItemWithCustomToolFake(initialCustomTool, initialNamespace);

            IServiceProvider sp = AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(codeProvider);

            ResourceEditorView.ResourceEditorAccessModifierCombobox combo =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    resXFileType == ResXFileType.DefaultResX,
                    allowNoCodeGeneration,
                    designer,
                    sp,
                    projectItem,
                    codeProvider is VBCodeProvider ? "My.Resources" : null
                    );
            Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor =
                new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo);

            // Call the method under test
            accessor.SetCurrentValue(newCurrentValue);

            // Verify results
            Assert.AreEqual(expectedCustomTool, projectItem.Fake_PropertiesCollection.Item("CustomTool").Value);
            Assert.AreEqual(expectedNamespace, projectItem.Fake_PropertiesCollection.Item("CustomToolNamespace").Value);
        }
コード例 #2
0
        public void GetDropdownValuesCSharp()
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();

            ResourceEditorView.ResourceEditorAccessModifierCombobox combo =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    false,
                    false,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(new CSharpCodeProvider()),
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);

            CollectionAssert.AreEqual(new string[] { "Internal", "Public" }, combo.GetDropdownValues());

            combo =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    false,
                    true,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(new CSharpCodeProvider()),
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);

            CollectionAssert.AreEqual(new string[] { "Internal", "Public", "No code generation" }, combo.GetDropdownValues());
        }
コード例 #3
0
        public void GetMenuCommandsToRegister()
        {
            SD.SettingsDesigner designer = new SD.SettingsDesigner();
            SettingsDesignerAccessModifierComboboxSubclass combo =
                new SettingsDesignerAccessModifierComboboxSubclass(
                    true,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);

            List <MenuCommand> commands = new List <MenuCommand>();

            Guid      guid1      = new Guid("c2013470-51ac-4278-9ac5-389c72a1f926");
            Guid      guid2      = new Guid("c2013470-51ac-4278-9ac5-389c72a1f926");
            CommandID commandId1 = new CommandID(guid1, 0x2106);
            CommandID commandId2 = new CommandID(guid2, 0x2107);

            foreach (MenuCommand cmd in combo.GetMenuCommandsToRegister())
            {
                commands.Add(cmd);
            }

            Assert.IsInstanceOfType(commands[0], typeof(DesignerCommandBarComboBox), "Should have created a combobox menu item and a filler menu item");
            Assert.IsInstanceOfType(commands[1], typeof(DesignerCommandBarComboBoxFiller));

            Assert.AreEqual(commandId1, commands[0].CommandID);
            Assert.AreEqual(commandId2, commands[1].CommandID);

            Assert.IsTrue(combo.Fake_isMenuCommandForwarderRegistered);
        }
コード例 #4
0
        public void GetMenuCommandsToRegister()
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();
            ResourceEditorAccessModifierComboboxSubclass combo =
                new ResourceEditorAccessModifierComboboxSubclass(
                    true,
                    false,
                    false,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);

            List <MenuCommand> commands = new List <MenuCommand>();

            Guid      guid1      = new Guid("66BD4C1D-3401-4bcc-A942-E4990827E6F7");
            Guid      guid2      = new Guid("66BD4C1D-3401-4bcc-A942-E4990827E6F7");
            CommandID commandId1 = new CommandID(guid1, 0x2061);
            CommandID commandId2 = new CommandID(guid2, 0x2062);

            foreach (MenuCommand cmd in combo.GetMenuCommandsToRegister())
            {
                commands.Add(cmd);
            }

            Assert.IsInstanceOfType(commands[0], typeof(DesignerCommandBarComboBox), "Should have created a combobox menu item and a filler menu item");
            Assert.IsInstanceOfType(commands[1], typeof(DesignerCommandBarComboBoxFiller));

            Assert.AreEqual(commandId1, commands[0].CommandID);
            Assert.AreEqual(commandId2, commands[1].CommandID);

            Assert.IsTrue(combo.Fake_isMenuCommandForwarderRegistered);
        }
コード例 #5
0
 public void ConstructorRootDesignerNull()
 {
     SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x =
         new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox(
             null,
             AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
             new Mock <EnvDTE.ProjectItem>().Instance,
             null);
 }
コード例 #6
0
 public void ConstructorProjectItemNull()
 {
     SD.SettingsDesigner designer = new SD.SettingsDesigner();
     SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x =
         new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox(
             designer,
             AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
             null,
             null);
 }
コード例 #7
0
 public void ConstructorRootDesignerNull()
 {
     ResourceEditorView.ResourceEditorAccessModifierCombobox x =
         new ResourceEditorView.ResourceEditorAccessModifierCombobox(
             false,
             false,
             null,
             AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
             new Mock <EnvDTE.ProjectItem>().Instance,
             null);
 }
コード例 #8
0
        public void GetDropdownValuesCSharp()
        {
            SD.SettingsDesigner designer = new SD.SettingsDesigner();
            SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox combo =
                new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox(
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(new CSharpCodeProvider()),
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);

            CollectionAssert.AreEqual(new string[] { "Internal", "Public" }, combo.GetDropdownValues());
        }
コード例 #9
0
        public void ConstructorProjectItemNull()
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();

            ResourceEditorView.ResourceEditorAccessModifierCombobox x =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    false,
                    false,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
                    null,
                    null);
        }
コード例 #10
0
        static void TestIsEnabled(bool expectedIsEnabled, ResXFileType resXFileType, object initialCustomToolValue, bool supportCustomToolValueInProject, CodeDomProvider codeProvider)
        {
            if (resXFileType == ResXFileType.DefaultResX)
            {
                Assert.IsTrue(codeProvider == null || codeProvider is VBCodeProvider, "Problem in the unit test itself: don't pass in ResXFileType.DefaultResX except for VB");
            }

            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();
            ProjectItemFake            projectItem;

            if (supportCustomToolValueInProject)
            {
                projectItem = new ProjectItemWithCustomToolFake(initialCustomToolValue);
            }
            else
            {
                projectItem = new ProjectItemFake();
            }

            IServiceProvider sp = AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(codeProvider);

            ResourceEditorAccessModifierComboboxSubclass combo =
                new ResourceEditorAccessModifierComboboxSubclass(
                    true,
                    resXFileType == ResXFileType.DefaultResX,
                    !(resXFileType == ResXFileType.DefaultResX),
                    designer,
                    sp,
                    projectItem,
                    codeProvider is VBCodeProvider ? "My.Resources" : null
                    );
            Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor =
                new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo);

            Assert.AreEqual(expectedIsEnabled, accessor.ShouldBeEnabled());
        }