コード例 #1
0
        public void EditProjectFile_WhenAnyConfig_ThenShowMessageBoxAndAddXmlDataToProjectFileAndSave()
        {
            //Arrange
            var vsServices = new Mock <IVsServices>();
            var projectXml = new Mock <IVsProjectXmlTransform>();

            ConfigTransformManager.VsService           = vsServices.Object;
            ConfigTransformManager.ProjectXmlTransform = projectXml.Object;

            vsServices.Setup(
                s =>
                s.ShowMessageBox(It.IsAny <string>(), It.IsAny <string>(), OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                                 OLEMSGICON.OLEMSGICON_QUERY)).Returns(6).Verifiable();

            var solutionTestHelper = new SolutionTestHelper();

            solutionTestHelper.CreateSolution();

            //Act
            var isSaved = ConfigTransformManager.EditProjectFile(solutionTestHelper.AnyConfigProjectItemMock.Object);

            //Assert
            solutionTestHelper.ProjectTargetMock.Verify(v => v.Save(It.IsAny <string>()));
            projectXml.Verify(v => v.AddTransformTask());
            projectXml.Verify(v => v.AddAfterBuildTarget(RootAnyConfig, @"..\my.common", true));
            projectXml.Verify(v => v.Save());
        }
コード例 #2
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var          editProjectFile = ConfigTransformManager.EditProjectFile(_selectedProjectItem);
            const string reloadMessage   = @"Changes were made in project file.";
            const string noChangeMessage = @"No changes were made.";
            var          displayMessage  = editProjectFile ? reloadMessage : noChangeMessage;

            // Show a Message Box
            VsServices.Instance.ShowMessageBox(displayMessage);
        }