void ISolutionConfigurationManagement.Save(bool prompt) { m_Server.Save(this); this.SelectSavePath(prompt, SetupFileDialog); List <UAModelDesignerProject> _projects = new List <UAModelDesignerProject>(); foreach (IProjectConfigurationManagement _item in m_Projects) { UAModelDesignerProject _projectDescriptor = _item.UAModelDesignerProject; string _effectiveAbsolutePath = _item.DefaultFileName; _projectDescriptor.FileName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _effectiveAbsolutePath); } string _codebaseRelativePathName = string.Empty; string _configurationRelativePathName = string.Empty; ServerSelector.ServerDescriptor _plugin = m_Server.ServerConfiguration; if (_plugin != null) { _codebaseRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Codebase); _configurationRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Configuration); } UAModelDesignerSolution _solutionDesription = new UAModelDesignerSolution() { Name = this.m_Name, Projects = m_Projects.Select <IProjectConfigurationManagement, UAModelDesignerProject>(x => x.UAModelDesignerProject).ToArray <UAModelDesignerProject>(), ServerDetails = new UAModelDesignerSolutionServerDetails { codebase = _codebaseRelativePathName, configuration = _configurationRelativePathName } }; this.Save(_solutionDesription); }
public void GetPluginRelativePathNamesXTest() { Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>(); _directory.SetupGet(x => x.DefaultDirectory).Returns(Directory.GetCurrentDirectory()); Mock <IGraphicalUserInterface> _gui = new Mock <IGraphicalUserInterface>(); Mock <IFileDialog> _openFileDialogMock = new Mock <IFileDialog>(); Mock <IFolderBrowserDialog> _IFolderBrowserDialog = new Mock <IFolderBrowserDialog>(); string _message = String.Empty; string _caption = String.Empty; _gui.Setup(x => x.MessageBoxShowWarning); _gui.Setup(x => x.MessageBoxShowError); _gui.SetupGet(x => x.MessageBoxShowExclamation).Returns(() => (message, caption) => { _message = message; _caption = caption; }); _gui.SetupGet(x => x.OpenFileDialogFunc).Returns(() => () => _openFileDialogMock.Object); _gui.SetupGet(x => x.OpenFolderBrowserDialogFunc).Returns(() => () => _IFolderBrowserDialog.Object); ServerSelector _underTestItem = new ServerSelector(_gui.Object, _directory.Object, m_PluginFullPath, ""); ServerSelector.ServerDescriptor _pluginPaths = _underTestItem.ServerConfiguration; //test behavior _gui.Verify(x => x.MessageBoxShowError, Times.Never); _gui.Verify(x => x.MessageBoxShowWarning, Times.Never); _gui.Verify(x => x.MessageBoxShowExclamation, Times.Exactly(2)); _gui.Verify(x => x.OpenFileDialogFunc, Times.Once); _gui.Verify(x => x.OpenFolderBrowserDialogFunc, Times.Once); //test result Assert.IsNotNull(_pluginPaths); Assert.AreEqual <string>(m_ConfigurationDefaultFileName, _pluginPaths.Configuration); Assert.AreEqual <string>(m_PluginFullPath, _pluginPaths.Codebase); }