Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public void ConstructorProjectItemNull()
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();

            ResourceEditorView.ResourceEditorAccessModifierCombobox x =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    false,
                    false,
                    designer,
                    AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
                    null,
                    null);
        }
Esempio n. 5
0
        public void ConstructorServiceProviderNull()
        {
            ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner();

            ResourceEditorView.ResourceEditorAccessModifierCombobox x =
                new ResourceEditorView.ResourceEditorAccessModifierCombobox(
                    false,
                    true,
                    designer,
                    null,
                    new Mock <EnvDTE.ProjectItem>().Instance,
                    null);
        }
Esempio n. 6
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());
        }