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); }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion #region "Utilities" public void TestGetCurrentValue(string expectedCurrentValue, object customToolValue, bool supportCustomToolValueInProject, CodeDomProvider codeProvider) { SD.SettingsDesigner designer = new SD.SettingsDesigner(); ProjectItemFake projectItem; if (supportCustomToolValueInProject) { projectItem = new ProjectItemWithCustomToolFake(customToolValue); } else { projectItem = new ProjectItemFake(); } Mock <IVSMDCodeDomProvider> vsmdCodeDomProviderMock = new Mock <IVSMDCodeDomProvider>(); vsmdCodeDomProviderMock.Implement("get_CodeDomProvider", codeProvider); ServiceProviderMock spMock = new ServiceProviderMock(); if (codeProvider != null) { spMock.Fake_AddService(typeof(IVSMDCodeDomProvider), vsmdCodeDomProviderMock.Instance); } else { spMock.Fake_AddService(typeof(IVSMDCodeDomProvider), null); } SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox combo = new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox( designer, spMock.Instance, projectItem, codeProvider is VBCodeProvider ? "My" : null); Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor = new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo); Assert.AreEqual(expectedCurrentValue, accessor.GetCurrentValue()); }
static void TestSetCurrentValue(CodeDomProvider codeProvider, string initialCustomTool, string initialNamespace, string newCurrentValue, string expectedCustomTool, string expectedNamespace) { SD.SettingsDesigner designer = new SD.SettingsDesigner(); ProjectItemFake projectItem; projectItem = new ProjectItemWithCustomToolFake(initialCustomTool, initialNamespace); Mock <IVSMDCodeDomProvider> vsmdCodeDomProviderMock = new Mock <IVSMDCodeDomProvider>(); vsmdCodeDomProviderMock.Implement("get_CodeDomProvider", codeProvider); ServiceProviderMock spMock = new ServiceProviderMock(); if (codeProvider != null) { spMock.Fake_AddService(typeof(IVSMDCodeDomProvider), vsmdCodeDomProviderMock.Instance); } else { spMock.Fake_AddService(typeof(IVSMDCodeDomProvider), null); } SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox combo = new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox( designer, spMock.Instance, projectItem, codeProvider is VBCodeProvider ? "My" : 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); }
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()); }