Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ward <matt.ward@xamarin.com>2017-07-25 15:53:09 +0300
committerMatt Ward <matt.ward@xamarin.com>2017-07-26 12:32:20 +0300
commita318bb7db4a11c27f946a6265f7847b86ed5a69b (patch)
treed714fc2df8ad5705b26504561b126cb608b06d39 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects
parentc8cbb66f1a42278be73fd8af817df6f0be75bfc6 (diff)
[Ide] Add tests for New Project dialog's create directory check box
Added unit tests for the logic of whether the create directory check box on the final page of the New Project dialog is enabled and checked before fixing a bug in this logic.
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs28
1 files changed, 21 insertions, 7 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs
index d906a3910a..4bab7ef0b5 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs
@@ -57,7 +57,7 @@ namespace MonoDevelop.Ide.Projects
const string UseGitPropertyName = "Dialogs.NewProjectDialog.UseGit";
const string CreateGitIgnoreFilePropertyName = "Dialogs.NewProjectDialog.CreateGitIgnoreFile";
- const string CreateProjectSubDirectoryPropertyName = "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir";
+ internal const string CreateProjectSubDirectoryPropertyName = "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir";
const string NewSolutionLastSelectedCategoryPropertyName = "Dialogs.NewProjectDialog.LastSelectedCategoryPath";
const string NewSolutionLastSelectedTemplatePropertyName = "Dialogs.NewProjectDialog.LastSelectedTemplate";
const string NewProjectLastSelectedCategoryPropertyName = "Dialogs.NewProjectDialog.AddNewProjectLastSelectedCategoryPath";
@@ -268,7 +268,7 @@ namespace MonoDevelop.Ide.Projects
PropertyService.Set (CreateGitIgnoreFilePropertyName, projectConfiguration.CreateGitIgnoreFile);
}
- INewProjectDialogBackend CreateNewProjectDialog ()
+ protected virtual INewProjectDialogBackend CreateNewProjectDialog ()
{
return new GtkNewProjectDialogBackend ();
}
@@ -315,11 +315,25 @@ namespace MonoDevelop.Ide.Projects
void LoadTemplateCategories ()
{
Predicate<SolutionTemplate> templateMatch = GetTemplateFilter ();
- templateCategories = IdeApp.Services.TemplatingService.GetProjectTemplateCategories (templateMatch).ToList ();
+ templateCategories = TemplatingService.GetProjectTemplateCategories (templateMatch).ToList ();
if (IsNewSolution)
- recentTemplates = IdeApp.Services.TemplatingService.RecentTemplates.GetTemplates (templateCategories).Where (t => t.IsMatch (SolutionTemplateVisibility.NewSolution)).ToList ();
+ recentTemplates = TemplatingService.RecentTemplates.GetTemplates (templateCategories).Where (t => t.IsMatch (SolutionTemplateVisibility.NewSolution)).ToList ();
else
- recentTemplates = IdeApp.Services.TemplatingService.RecentTemplates.GetTemplates (templateCategories).ToList ();
+ recentTemplates = TemplatingService.RecentTemplates.GetTemplates (templateCategories).ToList ();
+ }
+
+ // Allow testing of the controller by allowing tests to specific the
+ // TemplatingService. IdeApp.Services is not initialized during unit tests.
+ TemplatingService templatingService;
+
+ internal TemplatingService TemplatingService {
+ get {
+ if (templatingService != null)
+ return templatingService;
+
+ return IdeApp.Services.TemplatingService;
+ }
+ set { templatingService = value; }
}
Predicate<SolutionTemplate> GetTemplateFilter ()
@@ -480,7 +494,7 @@ namespace MonoDevelop.Ide.Projects
// Fallback to checking all templates that match the template id in the same category
// and support the condition.
- SolutionTemplate matchedTemplate = IdeApp.Services.TemplatingService.GetTemplate (
+ SolutionTemplate matchedTemplate = TemplatingService.GetTemplate (
templateCategories,
currentTemplate => IsTemplateMatch (currentTemplate, SelectedTemplate, language, finalConfigurationPage.Parameters),
category => true,
@@ -746,7 +760,7 @@ namespace MonoDevelop.Ide.Projects
DisposeExistingNewItems ();
try {
- result = await IdeApp.Services.TemplatingService.ProcessTemplate (template, projectConfiguration, ParentFolder);
+ result = await TemplatingService.ProcessTemplate (template, projectConfiguration, ParentFolder);
if (!result.WorkspaceItems.Any ())
return false;
} catch (UserException ex) {