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

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

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

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

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

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

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

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

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

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

@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Tree @@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Tree
DerivedUnitTestsPad pad;
Solution solution;
MSBuildBasedProject project;
MockProjectContent projectContent;
[TestFixtureSetUp]
public void SetUpFixture()
@ -36,9 +37,10 @@ namespace UnitTesting.Tests.Tree @@ -36,9 +37,10 @@ namespace UnitTesting.Tests.Tree
[SetUp]
public void Init()
{
projectContent = new MockProjectContent();
pad.ProjectContent = projectContent;
solution = new Solution();
project = new MockCSharpProject();
MockProjectContent projectContent = pad.ProjectContent;
projectContent.Project = project;
projectContent.Language = LanguageProperties.None;
ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project);
@ -340,5 +342,33 @@ namespace UnitTesting.Tests.Tree @@ -340,5 +342,33 @@ namespace UnitTesting.Tests.Tree
{
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 @@ -65,7 +65,7 @@ namespace UnitTesting.Tests.Tree
// Init mock project content to be returned.
dummyTreeView = new DummyParserServiceTestTreeView();
dummyTreeView.AddProjectContentForProject(projectContent);
dummyTreeView.ProjectContentForProject = projectContent;
// Load the projects into the test tree view.
treeView = dummyTreeView as TestTreeView;

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

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

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

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

Loading…
Cancel
Save