34 changed files with 570 additions and 297 deletions
@ -1,50 +0,0 @@
@@ -1,50 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.PackageManagement |
||||
{ |
||||
public class NewProjectsCreated |
||||
{ |
||||
ProjectCreateInformation createInfo; |
||||
OpenMSBuildProjects openProjects; |
||||
|
||||
public NewProjectsCreated( |
||||
ProjectCreateInformation createInfo, |
||||
IPackageManagementProjectService projectService) |
||||
: this(createInfo, new OpenMSBuildProjects(projectService)) |
||||
{ |
||||
} |
||||
|
||||
public NewProjectsCreated( |
||||
ProjectCreateInformation createInfo, |
||||
OpenMSBuildProjects openProjects) |
||||
{ |
||||
this.createInfo = createInfo; |
||||
this.openProjects = openProjects; |
||||
} |
||||
|
||||
public IEnumerable<MSBuildBasedProject> GetProjects() |
||||
{ |
||||
// ProjectCreateInformation is no longer used to collect the results of the whole solution creation,
|
||||
// there now is a separate instance per project.
|
||||
#warning Reimplement PackageManagement.NewProjectsCreated
|
||||
throw new NotImplementedException(); |
||||
/*foreach (IProject project in createInfo.CreatedProjects) { |
||||
MSBuildBasedProject openProject = FindProject(project.Name); |
||||
if (openProject != null) { |
||||
yield return openProject; |
||||
} |
||||
}*/ |
||||
} |
||||
|
||||
MSBuildBasedProject FindProject(string name) |
||||
{ |
||||
return openProjects.FindProject(name); |
||||
} |
||||
} |
||||
} |
||||
@ -1,102 +0,0 @@
@@ -1,102 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PackageManagement; |
||||
using ICSharpCode.PackageManagement.Design; |
||||
using ICSharpCode.SharpDevelop.Internal.Templates; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using NUnit.Framework; |
||||
using PackageManagement.Tests.Helpers; |
||||
|
||||
namespace PackageManagement.Tests |
||||
{ |
||||
[TestFixture, IgnoreAttribute("NewProjectsCreated currently not implemented")] |
||||
public class NewProjectsCreatedTests |
||||
{ |
||||
FakePackageManagementProjectService fakeProjectService; |
||||
NewProjectsCreated newProjectsCreated; |
||||
|
||||
TestableProject CreateProject(string name) |
||||
{ |
||||
return ProjectHelper.CreateTestProject(name); |
||||
} |
||||
|
||||
ProjectCreateInformation CreateProjectCreateInfo(MSBuildBasedProject project) |
||||
{ |
||||
var projects = new List<MSBuildBasedProject>(); |
||||
projects.Add(project); |
||||
return CreateProjectCreateInfo(projects); |
||||
} |
||||
|
||||
ProjectCreateInformation CreateProjectCreateInfo(IEnumerable<MSBuildBasedProject> projects) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
//return new ProjectCreateInformation(projects);
|
||||
} |
||||
|
||||
void CreateNewProjectsCreated(ProjectCreateInformation createInfo) |
||||
{ |
||||
fakeProjectService = new FakePackageManagementProjectService(); |
||||
newProjectsCreated = new NewProjectsCreated(createInfo, fakeProjectService); |
||||
} |
||||
|
||||
TestableProject AddProjectToProjectServiceOpenProjects(string projectName) |
||||
{ |
||||
TestableProject project = CreateProject(projectName); |
||||
fakeProjectService.AddProject(project); |
||||
return project; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProjects_OneProjectCreatedAndOneOldProjectInSolution_ReturnsProjectFromProjectService() |
||||
{ |
||||
TestableProject project = CreateProject("TestProject"); |
||||
ProjectCreateInformation createInfo = CreateProjectCreateInfo(project); |
||||
CreateNewProjectsCreated(createInfo); |
||||
AddProjectToProjectServiceOpenProjects("OriginalProject"); |
||||
TestableProject expectedProject = AddProjectToProjectServiceOpenProjects("TestProject"); |
||||
|
||||
var projects = new List<MSBuildBasedProject>(); |
||||
projects.AddRange(newProjectsCreated.GetProjects()); |
||||
|
||||
var expectedProjects = new MSBuildBasedProject[] { |
||||
expectedProject |
||||
}; |
||||
|
||||
Assert.AreEqual(expectedProjects, projects); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProjects_OneProjectCreatedWithDifferentNameCase_ReturnsProjectFromProjectService() |
||||
{ |
||||
TestableProject project = CreateProject("TESTPROJECT"); |
||||
ProjectCreateInformation createInfo = CreateProjectCreateInfo(project); |
||||
CreateNewProjectsCreated(createInfo); |
||||
TestableProject expectedProject = AddProjectToProjectServiceOpenProjects("TestProject"); |
||||
|
||||
var projects = new List<MSBuildBasedProject>(); |
||||
projects.AddRange(newProjectsCreated.GetProjects()); |
||||
|
||||
var expectedProjects = new MSBuildBasedProject[] { |
||||
expectedProject |
||||
}; |
||||
|
||||
Assert.AreEqual(expectedProjects, projects); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProjects_OneProjectCreatedButProjectIsNotOpen_ReturnsNoProjects() |
||||
{ |
||||
TestableProject project = CreateProject("TestProject"); |
||||
ProjectCreateInformation createInfo = CreateProjectCreateInfo(project); |
||||
CreateNewProjectsCreated(createInfo); |
||||
|
||||
var projects = new List<MSBuildBasedProject>(); |
||||
projects.AddRange(newProjectsCreated.GetProjects()); |
||||
|
||||
Assert.AreEqual(0, projects.Count); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Threading; |
||||
using ICSharpCode.NRefactory.Utils; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Dom |
||||
{ |
||||
/// <summary>
|
||||
/// Synchronizing wrapper around IMutableModelCollection.
|
||||
/// </summary>
|
||||
public class SynchronizedModelCollection<T> : IMutableModelCollection<T> |
||||
{ |
||||
readonly IMutableModelCollection<T> underlyingCollection; |
||||
readonly object syncRoot; |
||||
|
||||
public SynchronizedModelCollection(IMutableModelCollection<T> underlyingCollection) |
||||
: this(underlyingCollection, new object()) |
||||
{ |
||||
} |
||||
|
||||
public SynchronizedModelCollection(IMutableModelCollection<T> underlyingCollection, object syncRoot) |
||||
{ |
||||
if (underlyingCollection == null) |
||||
throw new ArgumentNullException("underlyingCollection"); |
||||
if (syncRoot == null) |
||||
throw new ArgumentNullException("syncRoot"); |
||||
this.underlyingCollection = underlyingCollection; |
||||
this.syncRoot = syncRoot; |
||||
} |
||||
|
||||
// Event registration is thread-safe on the underlying collection
|
||||
public event ModelCollectionChangedEventHandler<T> CollectionChanged { |
||||
add { underlyingCollection.CollectionChanged += value; } |
||||
remove { underlyingCollection.CollectionChanged -= value; } |
||||
} |
||||
|
||||
#region IMutableModelCollection implementation
|
||||
|
||||
public void Clear() |
||||
{ |
||||
lock (syncRoot) { |
||||
underlyingCollection.Clear(); |
||||
} |
||||
} |
||||
|
||||
public void Add(T item) |
||||
{ |
||||
lock (syncRoot) { |
||||
underlyingCollection.Add(item); |
||||
} |
||||
} |
||||
|
||||
public void AddRange(IEnumerable<T> items) |
||||
{ |
||||
lock (syncRoot) { |
||||
underlyingCollection.AddRange(items); |
||||
} |
||||
} |
||||
|
||||
public bool Remove(T item) |
||||
{ |
||||
lock (syncRoot) { |
||||
return underlyingCollection.Remove(item); |
||||
} |
||||
} |
||||
|
||||
public int RemoveAll(Predicate<T> predicate) |
||||
{ |
||||
lock (syncRoot) { |
||||
return underlyingCollection.RemoveAll(predicate); |
||||
} |
||||
} |
||||
|
||||
public IDisposable BatchUpdate() |
||||
{ |
||||
Monitor.Enter(syncRoot); |
||||
IDisposable disposable = underlyingCollection.BatchUpdate(); |
||||
return new CallbackOnDispose( |
||||
delegate { |
||||
if (disposable != null) |
||||
disposable.Dispose(); |
||||
Monitor.Exit(syncRoot); |
||||
}); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region ICollection implementation
|
||||
|
||||
public bool Contains(T item) |
||||
{ |
||||
lock (syncRoot) { |
||||
return underlyingCollection.Contains(item); |
||||
} |
||||
} |
||||
|
||||
public void CopyTo(T[] array, int arrayIndex) |
||||
{ |
||||
lock (syncRoot) { |
||||
underlyingCollection.CopyTo(array, arrayIndex); |
||||
} |
||||
} |
||||
|
||||
public int Count { |
||||
get { |
||||
lock (syncRoot) { |
||||
return underlyingCollection.Count; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public bool IsReadOnly { |
||||
get { |
||||
lock (syncRoot) { |
||||
return underlyingCollection.IsReadOnly; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public IEnumerator<T> GetEnumerator() |
||||
{ |
||||
IEnumerable<T> snapshot; |
||||
lock (syncRoot) { |
||||
T[] array = new T[underlyingCollection.Count]; |
||||
underlyingCollection.CopyTo(array, 0); |
||||
snapshot = array; |
||||
} |
||||
return snapshot.GetEnumerator(); |
||||
} |
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
||||
{ |
||||
return GetEnumerator(); |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
||||
Loading…
Reference in new issue