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); }
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()); }
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); }
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); }
public void ConstructorRootDesignerNull() { SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x = new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox( null, AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null), new Mock <EnvDTE.ProjectItem>().Instance, null); }
public void ConstructorProjectItemNull() { SD.SettingsDesigner designer = new SD.SettingsDesigner(); SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x = new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox( designer, AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null), null, null); }
public void ConstructorRootDesignerNull() { ResourceEditorView.ResourceEditorAccessModifierCombobox x = new ResourceEditorView.ResourceEditorAccessModifierCombobox( false, false, null, AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null), new Mock <EnvDTE.ProjectItem>().Instance, null); }
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()); }
public void ConstructorProjectItemNull() { ResourceEditorRootDesigner designer = new ResourceEditorRootDesigner(); ResourceEditorView.ResourceEditorAccessModifierCombobox x = new ResourceEditorView.ResourceEditorAccessModifierCombobox( false, false, designer, AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null), null, null); }
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()); }