Esempio n. 1
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);
        }
Esempio n. 2
0
 public void ConstructorProjectItemNull()
 {
     SD.SettingsDesigner designer = new SD.SettingsDesigner();
     SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x =
         new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox(
             designer,
             AccessModifierComboboxTests.CreateServiceProviderWithIVSMDCodeDomProvider(null),
             null,
             null);
 }
Esempio n. 3
0
 public void ConstructorServiceProviderNull()
 {
     SD.SettingsDesigner designer = new SD.SettingsDesigner();
     SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox x =
         new SD.SettingsDesignerView.SettingsDesignerAccessModifierCombobox(
             designer,
             null,
             new Mock <EnvDTE.ProjectItem>().Instance,
             null);
 }
Esempio n. 4
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());
        }
        public void DisabledWhenCustomToolNotRecognizedAndNonEmpty()
        {
            SD.SettingsDesigner designer           = new SD.SettingsDesigner();
            SubclassedAccessModifierCombobox combo =
                new SubclassedAccessModifierCombobox(
                    designer,
                    designer,
                    new ProjectItemWithCustomToolFake("WhoAmI"),
                    true,
                    null);

            Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor =
                new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo);

            Assert.IsFalse(accessor.ShouldBeEnabled());
        }
        public void EnabledWhenCustomToolRecognized()
        {
            SD.SettingsDesigner designer           = new SD.SettingsDesigner();
            SubclassedAccessModifierCombobox combo =
                new SubclassedAccessModifierCombobox(
                    designer,
                    designer,
                    new ProjectItemWithCustomToolFake("Recognized generator"),
                    true,
                    null);

            combo.AddCodeGeneratorEntry("Hi, Mom", "Recognized generator");

            Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor =
                new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo);

            Assert.IsTrue(accessor.ShouldBeEnabled());
        }
        public void EnabledWhenCustomToolRecognizedButNotInDropdownList()
        {
            SD.SettingsDesigner designer           = new SD.SettingsDesigner();
            SubclassedAccessModifierCombobox combo =
                new SubclassedAccessModifierCombobox(
                    designer,
                    designer,
                    new ProjectItemWithCustomToolFake("ResXFileCodeGenerator"),
                    true,
                    null);

            combo.AddCodeGeneratorEntry("VbMyResourcesResXFileCodeGenerator", "Expected generator");
            combo.AddRecognizedCustomToolValue("ResXFileCodeGenerator");

            Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor accessor =
                new Microsoft_VisualStudio_Editors_DesignerFramework_AccessModifierComboboxAccessor(combo);

            Assert.IsTrue(accessor.ShouldBeEnabled());
        }
Esempio n. 8
0
        //
        // 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());
        }
Esempio n. 9
0
        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);
        }