19 changed files with 337 additions and 60 deletions
@ -0,0 +1,13 @@ |
|||||||
|
// 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; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public static class Constants |
||||||
|
{ |
||||||
|
public static readonly string VsProjectItemKindPhysicalFile = "{6BB5F8EE-4483-11D3-8BCF-00C04F8EC28C}"; |
||||||
|
public static readonly string VsProjectItemKindPhysicalFolder = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}"; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
// 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 SD = ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.PackageManagement.EnvDTE |
||||||
|
{ |
||||||
|
public class ProjectKind |
||||||
|
{ |
||||||
|
public ProjectKind(Project project) |
||||||
|
{ |
||||||
|
this.Kind = GetProjectKind(project); |
||||||
|
} |
||||||
|
|
||||||
|
string GetProjectKind(Project project) |
||||||
|
{ |
||||||
|
string type = new ProjectType(project).Type; |
||||||
|
if (type == ProjectType.CSharp) { |
||||||
|
return SD.ProjectTypeGuids.CSharp; |
||||||
|
} else if (type == ProjectType.VBNet) { |
||||||
|
return SD.ProjectTypeGuids.VBNet; |
||||||
|
} |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
|
||||||
|
public string Kind { get; private set; } |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,105 @@ |
|||||||
|
// 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.Linq; |
||||||
|
using ICSharpCode.PackageManagement.Design; |
||||||
|
using ICSharpCode.PackageManagement.EnvDTE; |
||||||
|
using NUnit.Framework; |
||||||
|
using PackageManagement.Tests.Helpers; |
||||||
|
using SD = ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace PackageManagement.Tests.EnvDTE |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class SolutionTests |
||||||
|
{ |
||||||
|
Solution solution; |
||||||
|
FakePackageManagementProjectService fakeProjectService; |
||||||
|
SD.Solution sharpDevelopSolution; |
||||||
|
|
||||||
|
void CreateSolution() |
||||||
|
{ |
||||||
|
fakeProjectService = new FakePackageManagementProjectService(); |
||||||
|
sharpDevelopSolution = CreateSharpDevelopSolution(); |
||||||
|
fakeProjectService.OpenSolution = sharpDevelopSolution; |
||||||
|
solution = new Solution(fakeProjectService); |
||||||
|
} |
||||||
|
|
||||||
|
SD.Solution CreateSharpDevelopSolution() |
||||||
|
{ |
||||||
|
return new SD.Solution(new SD.MockProjectChangeWatcher()); |
||||||
|
} |
||||||
|
|
||||||
|
SD.Solution OpenDifferentSolution() |
||||||
|
{ |
||||||
|
SD.Solution solution = CreateSharpDevelopSolution(); |
||||||
|
fakeProjectService.OpenSolution = solution; |
||||||
|
return solution; |
||||||
|
} |
||||||
|
|
||||||
|
void NoOpenSolution() |
||||||
|
{ |
||||||
|
fakeProjectService.OpenSolution = null; |
||||||
|
} |
||||||
|
|
||||||
|
void AddProjectToSolution(string projectName) |
||||||
|
{ |
||||||
|
TestableProject project = ProjectHelper.CreateTestProject(projectName); |
||||||
|
fakeProjectService.AddFakeProject(project); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsOpen_NoOpenSolution_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateSolution(); |
||||||
|
NoOpenSolution(); |
||||||
|
|
||||||
|
bool open = solution.IsOpen; |
||||||
|
|
||||||
|
Assert.IsFalse(open); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsOpen_SolutionOpenInSharpDevelop_ReturnsTrue() |
||||||
|
{ |
||||||
|
CreateSolution(); |
||||||
|
|
||||||
|
bool open = solution.IsOpen; |
||||||
|
|
||||||
|
Assert.IsTrue(open); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsOpen_DifferentSolutionOpenInSharpDevelop_ReturnsFalse() |
||||||
|
{ |
||||||
|
CreateSolution(); |
||||||
|
OpenDifferentSolution(); |
||||||
|
|
||||||
|
bool open = solution.IsOpen; |
||||||
|
|
||||||
|
Assert.IsFalse(open); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Projects_SolutionHasNoProjects_NoProjectsInCollection() |
||||||
|
{ |
||||||
|
CreateSolution(); |
||||||
|
|
||||||
|
int count = solution.Projects.ToList().Count; |
||||||
|
|
||||||
|
Assert.AreEqual(0, count); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Projects_SolutionHasOnProject_OneProjectInCollection() |
||||||
|
{ |
||||||
|
CreateSolution(); |
||||||
|
AddProjectToSolution("MyProject"); |
||||||
|
|
||||||
|
Project project = solution.Projects.First(); |
||||||
|
|
||||||
|
Assert.AreEqual("MyProject", project.Name); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue