22// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
33
44using System ;
5+ using ICSharpCode . Core ;
6+ using ICSharpCode . SharpDevelop . Dom ;
57using ICSharpCode . SharpDevelop . Project ;
8+ using ICSharpCode . SharpDevelop . Workbench ;
69using Microsoft . Build . Execution ;
710using NUnit . Framework ;
811using Rhino . Mocks ;
@@ -12,19 +15,49 @@ namespace ICSharpCode.SharpDevelop
1215 [ TestFixture ]
1316 public class SolutionTests
1417 {
15- [ Test , Ignore ]
16- public void UpdateMSBuildProperties_SolutionHasFileName_SolutionDefinesSolutionDirMSBuildPropertyWithDirectoryEndingInForwardSlash ( )
18+ ISolution CreateSolution ( )
1719 {
18- /*CreateSolution();
19- solution.FileName = @"d:\projects\MyProject\MySolution.sln";
20-
21- solution.UpdateMSBuildProperties();
20+ IFileService fileService = MockRepository . GenerateStub < IFileService > ( ) ;
21+ IProjectChangeWatcher changeWatcher = MockRepository . GenerateStrictMock < IProjectChangeWatcher > ( ) ;
22+ return new Solution ( FileName . Create ( @"d:\projects\MyProject\MySolution.sln" ) , changeWatcher , fileService ) ;
23+ }
24+
25+ /// <summary>
26+ /// Create a dummy project that can be added to a solution.
27+ /// </summary>
28+ IProject CreateProject ( ISolution parentSolution )
29+ {
30+ var project = MockRepository . GenerateStrictMock < IProject > ( ) ;
31+ project . Stub ( p => p . ParentSolution ) . Return ( parentSolution ) ;
32+ project . Stub ( p => p . ParentFolder ) . PropertyBehavior ( ) ;
33+ project . Stub ( p => p . ProjectSections ) . Return ( new SimpleModelCollection < SolutionSection > ( ) ) ;
34+ project . Stub ( p => p . ConfigurationMapping ) . Return ( new ConfigurationMapping ( ) ) ;
35+ project . Stub ( p => p . IsStartable ) . Return ( false ) ;
36+ return project ;
37+ }
38+
39+ [ Test ]
40+ public void UpdateMSBuildProperties_SolutionHasFileName_SolutionDefinesSolutionDirMSBuildPropertyWithDirectoryEndingInSlash ( )
41+ {
42+ var solution = CreateSolution ( ) ;
2243
2344 ProjectPropertyInstance property = solution . MSBuildProjectCollection . GetGlobalProperty ( "SolutionDir" ) ;
2445 string solutionDir = property . EvaluatedValue ;
2546
2647 string expectedSolutionDir = @"d:\projects\MyProject\" ;
27- Assert.AreEqual(expectedSolutionDir, solutionDir);*/
48+ Assert . AreEqual ( expectedSolutionDir , solutionDir ) ;
49+ }
50+
51+ [ Test ]
52+ public void AddProjectToDisconnectedFolder ( )
53+ {
54+ var solution = CreateSolution ( ) ;
55+ var folder = solution . CreateFolder ( "folder" ) ;
56+ solution . Items . Remove ( folder ) ;
57+
58+ var project = CreateProject ( solution ) ;
59+ folder . Items . Add ( project ) ;
60+ Assert . IsEmpty ( solution . Projects ) ;
2861 }
2962 }
3063}
0 commit comments