Browse Source

SD2-1241. Fixed two problems in the Unit Tests pad that could occur when opening another solution before the parser has finished parsing the currently open solution. A) The ProjectService.OpenSolution could be null. The unit tests pad now clears the test tree in this case. B) If the project content is null for a project it is not added to the test tree. This can occur if the test tree is in the middle of updating the tree but the parser has cleared the project content as it starts to load another solution.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2145 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
b69d0fd504
  1. 15
      src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs
  2. 6
      src/AddIns/Misc/UnitTesting/Src/UnitTestsPad.cs
  3. 2
      src/AddIns/Misc/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs
  4. 2
      src/AddIns/Misc/UnitTesting/Test/Tree/GetProjectsTestFixture.cs
  5. 2
      src/AddIns/Misc/UnitTesting/Test/Tree/OneTestClassTestFixture.cs
  6. 32
      src/AddIns/Misc/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs
  7. 2
      src/AddIns/Misc/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs
  8. 7
      src/AddIns/Misc/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs
  9. 14
      src/AddIns/Misc/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs

15
src/AddIns/Misc/UnitTesting/Src/TestTreeView.cs

@ -83,12 +83,15 @@ namespace ICSharpCode.UnitTesting
if (TestProject.IsTestProject(project)) { if (TestProject.IsTestProject(project)) {
if (GetProjectTreeNode(project) == null) { if (GetProjectTreeNode(project) == null) {
// Add a new tree node. // Add a new tree node.
TestProject testProject = new TestProject(project, GetProjectContent(project)); IProjectContent projectContent = GetProjectContent(project);
TestProjectTreeNode node = new TestProjectTreeNode(testProject); if (projectContent != null) {
node.AddTo(this); TestProject testProject = new TestProject(project, projectContent);
TestProjectTreeNode node = new TestProjectTreeNode(testProject);
// Sort the nodes. node.AddTo(this);
SortNodes(Nodes, true);
// Sort the nodes.
SortNodes(Nodes, true);
}
} }
} }
} }

6
src/AddIns/Misc/UnitTesting/Src/UnitTestsPad.cs

@ -115,7 +115,11 @@ namespace ICSharpCode.UnitTesting
/// </summary> /// </summary>
protected void SolutionLoaded(Solution solution) protected void SolutionLoaded(Solution solution)
{ {
treeView.AddSolution(solution); if (solution != null) {
treeView.AddSolution(solution);
} else {
treeView.Clear();
}
} }
/// <summary> /// <summary>

2
src/AddIns/Misc/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs

@ -58,7 +58,7 @@ namespace UnitTesting.Tests.Tree
// Init mock project content to be returned. // Init mock project content to be returned.
dummyTreeView = new DummyParserServiceTestTreeView(); dummyTreeView = new DummyParserServiceTestTreeView();
dummyTreeView.AddProjectContentForProject(projectContent); dummyTreeView.ProjectContentForProject = projectContent;
// Load the projects into the test tree view. // Load the projects into the test tree view.
treeView = dummyTreeView as TestTreeView; treeView = dummyTreeView as TestTreeView;

2
src/AddIns/Misc/UnitTesting/Test/Tree/GetProjectsTestFixture.cs

@ -49,7 +49,7 @@ namespace UnitTesting.Tests.Tree
projectContent.Project = project1; projectContent.Project = project1;
treeView = new DummyParserServiceTestTreeView(); treeView = new DummyParserServiceTestTreeView();
treeView.AddProjectContentForProject(projectContent); treeView.ProjectContentForProject = projectContent;
treeView.AddSolution(solution); treeView.AddSolution(solution);
projects = treeView.GetProjects(); projects = treeView.GetProjects();
} }

2
src/AddIns/Misc/UnitTesting/Test/Tree/OneTestClassTestFixture.cs

@ -81,7 +81,7 @@ namespace UnitTesting.Tests.Tree
// Init mock project content to be returned. // Init mock project content to be returned.
dummyTreeView = new DummyParserServiceTestTreeView(); dummyTreeView = new DummyParserServiceTestTreeView();
dummyTreeView.AddProjectContentForProject(projectContent); dummyTreeView.ProjectContentForProject = projectContent;
// Load the projects into the test tree view. // Load the projects into the test tree view.
treeView = dummyTreeView as TestTreeView; treeView = dummyTreeView as TestTreeView;

32
src/AddIns/Misc/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs

@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Tree
DerivedUnitTestsPad pad; DerivedUnitTestsPad pad;
Solution solution; Solution solution;
MSBuildBasedProject project; MSBuildBasedProject project;
MockProjectContent projectContent;
[TestFixtureSetUp] [TestFixtureSetUp]
public void SetUpFixture() public void SetUpFixture()
@ -36,9 +37,10 @@ namespace UnitTesting.Tests.Tree
[SetUp] [SetUp]
public void Init() public void Init()
{ {
projectContent = new MockProjectContent();
pad.ProjectContent = projectContent;
solution = new Solution(); solution = new Solution();
project = new MockCSharpProject(); project = new MockCSharpProject();
MockProjectContent projectContent = pad.ProjectContent;
projectContent.Project = project; projectContent.Project = project;
projectContent.Language = LanguageProperties.None; projectContent.Language = LanguageProperties.None;
ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project);
@ -340,5 +342,33 @@ namespace UnitTesting.Tests.Tree
{ {
Assert.IsTrue(pad.GetOpenSolutionCalled); Assert.IsTrue(pad.GetOpenSolutionCalled);
} }
/// <summary>
/// Tests that a null solution clears the test tree.
/// </summary>
[Test]
public void NullSolution()
{
pad.CallSolutionLoaded(null);
Assert.AreEqual(0, pad.TestTreeView.Nodes.Count);
}
/// <summary>
/// If the user opens another solution before the parser thread
/// has finished we can sometimes get into a state where the
/// first solution is being loaded into the test tree view but
/// its project content has been removed since the parser is working
/// on the next solution that was opened. In this case the test
/// tree view should ignore any project's that have null project
/// contents.
/// </summary>
[Test]
public void NullProjectContent()
{
DummyParserServiceTestTreeView tree = (DummyParserServiceTestTreeView)pad.TestTreeView;
tree.ProjectContentForProject = null;
pad.CallSolutionLoaded(solution);
}
} }
} }

2
src/AddIns/Misc/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs

@ -65,7 +65,7 @@ namespace UnitTesting.Tests.Tree
// Init mock project content to be returned. // Init mock project content to be returned.
dummyTreeView = new DummyParserServiceTestTreeView(); dummyTreeView = new DummyParserServiceTestTreeView();
dummyTreeView.AddProjectContentForProject(projectContent); dummyTreeView.ProjectContentForProject = projectContent;
// Load the projects into the test tree view. // Load the projects into the test tree view.
treeView = dummyTreeView as TestTreeView; treeView = dummyTreeView as TestTreeView;

7
src/AddIns/Misc/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs

@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Utils
Solution openSolution; Solution openSolution;
bool loadSolutionProjectsThreadEndedHandled; bool loadSolutionProjectsThreadEndedHandled;
bool addedLoadSolutionProjectsThreadEndedHandler; bool addedLoadSolutionProjectsThreadEndedHandler;
DummyParserServiceTestTreeView treeView = new DummyParserServiceTestTreeView();
public DerivedUnitTestsPad(Solution openSolution) public DerivedUnitTestsPad(Solution openSolution)
{ {
@ -44,6 +45,10 @@ namespace UnitTesting.Tests.Utils
get { get {
return projectContent; return projectContent;
} }
set {
projectContent = value;
treeView.ProjectContentForProject = projectContent;
}
} }
public bool GetOpenSolutionCalled { public bool GetOpenSolutionCalled {
@ -130,8 +135,6 @@ namespace UnitTesting.Tests.Utils
/// </summary> /// </summary>
protected override TestTreeView CreateTestTreeView() protected override TestTreeView CreateTestTreeView()
{ {
DummyParserServiceTestTreeView treeView = new DummyParserServiceTestTreeView();
treeView.AddProjectContentForProject(projectContent);
return treeView; return treeView;
} }

14
src/AddIns/Misc/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs

@ -20,9 +20,17 @@ namespace UnitTesting.Tests.Utils
{ {
IProjectContent projectContent; IProjectContent projectContent;
public void AddProjectContentForProject(IProjectContent projectContent) /// <summary>
{ /// Gets or sets the project content that will be returned from the
this.projectContent = projectContent; /// GetProjectContent method.
/// </summary>
public IProjectContent ProjectContentForProject {
get {
return projectContent;
}
set {
projectContent = value;
}
} }
public override IProjectContent GetProjectContent(IProject project) public override IProjectContent GetProjectContent(IProject project)

Loading…
Cancel
Save