Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2142 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 330 additions and 59 deletions
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Tree |
||||
{ |
||||
/// <summary>
|
||||
/// Tests that if the parser is still running then we do not
|
||||
/// add the solution to the unit tests tree.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class OpenUnitTestsPadWithSolutionOpenTestFixture |
||||
{ |
||||
DerivedUnitTestsPad pad; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUp() |
||||
{ |
||||
Solution solution = new Solution(); |
||||
MockCSharpProject project = new MockCSharpProject(); |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
projectContent.Project = project; |
||||
projectContent.Language = LanguageProperties.None; |
||||
ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); |
||||
refProjectItem.Include = "NUnit.Framework"; |
||||
ProjectService.AddProjectItem(project, refProjectItem); |
||||
solution.Folders.Add(project); |
||||
|
||||
pad = new DerivedUnitTestsPad(solution); |
||||
} |
||||
|
||||
[TestFixtureTearDown] |
||||
public void TearDown() |
||||
{ |
||||
pad.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void NoSolutionAddedToTree() |
||||
{ |
||||
Assert.AreEqual(0, pad.TestTreeView.GetProjects().Length); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The LoadSolutionProjectsThreadEnded event handler needs to be
|
||||
/// added before the unit tests pad checks the
|
||||
/// LoadSolutionProjectsThreadRunning flag so we do not miss the
|
||||
/// event.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void ParserServiceLoadSolutionProjectsThreadEndedHandled() |
||||
{ |
||||
Assert.IsTrue(pad.LoadSolutionProjectsThreadEndedHandled); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Class that derives from UnitTestsPad so we can access protected
|
||||
/// methods and test it.
|
||||
/// </summary>
|
||||
public class DerivedUnitTestsPad : UnitTestsPad |
||||
{ |
||||
bool getOpenSolutionCalled; |
||||
bool isParserLoadingSolutionCalled; |
||||
MockProjectContent projectContent = new MockProjectContent(); |
||||
Solution openSolution; |
||||
bool loadSolutionProjectsThreadEndedHandled; |
||||
bool addedLoadSolutionProjectsThreadEndedHandler; |
||||
|
||||
public DerivedUnitTestsPad(Solution openSolution) |
||||
{ |
||||
this.openSolution = openSolution; |
||||
} |
||||
|
||||
public DerivedUnitTestsPad() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the project content to be used when creating the
|
||||
/// derived test tree view.
|
||||
/// </summary>
|
||||
public MockProjectContent ProjectContent { |
||||
get { |
||||
return projectContent; |
||||
} |
||||
} |
||||
|
||||
public bool GetOpenSolutionCalled { |
||||
get { |
||||
return getOpenSolutionCalled; |
||||
} |
||||
} |
||||
|
||||
public bool IsParserLoadingSolutionCalled { |
||||
get { |
||||
return isParserLoadingSolutionCalled; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks whether the ParserService's LoadSolutionProjectsThreadEnded event
|
||||
/// is mapped to an event handler before IsParserLoadingSolution is
|
||||
/// called. This ensures we do not miss this event.
|
||||
/// </summary>
|
||||
public bool LoadSolutionProjectsThreadEndedHandled { |
||||
get { |
||||
return loadSolutionProjectsThreadEndedHandled; |
||||
} |
||||
} |
||||
|
||||
public void CallSolutionLoaded(Solution solution) |
||||
{ |
||||
base.SolutionLoaded(solution); |
||||
} |
||||
|
||||
public void CallSolutionClosed() |
||||
{ |
||||
base.SolutionClosed(); |
||||
} |
||||
|
||||
public void CallProjectItemRemoved(ProjectItem item) |
||||
{ |
||||
base.ProjectItemRemoved(item); |
||||
} |
||||
|
||||
public void CallProjectItemAdded(ProjectItem item) |
||||
{ |
||||
base.ProjectItemAdded(item); |
||||
} |
||||
|
||||
public void CallProjectAdded(IProject project) |
||||
{ |
||||
base.ProjectAdded(project); |
||||
} |
||||
|
||||
public void CallSolutionFolderRemoved(ISolutionFolder folder) |
||||
{ |
||||
base.SolutionFolderRemoved(folder); |
||||
} |
||||
|
||||
public void CallUpdateParseInfo(ICompilationUnit oldUnit, ICompilationUnit newUnit) |
||||
{ |
||||
base.UpdateParseInfo(oldUnit, newUnit); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns a dummy toolstrip so the UnitTestsPad can be
|
||||
/// tested. If the default method is called the AddInTree
|
||||
/// is referenced which is not available during testing.
|
||||
/// </summary>
|
||||
protected override ToolStrip CreateToolStrip(string name) |
||||
{ |
||||
return new ToolStrip(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns a dummy ContextMenuStrip so the UnitTestsPad can be
|
||||
/// tested. If the default method is called the AddInTree
|
||||
/// is referenced which is not available during testing.
|
||||
/// </summary>
|
||||
protected override ContextMenuStrip CreateContextMenu(string name) |
||||
{ |
||||
return new ContextMenuStrip(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns a dummy tree view where we can mock the
|
||||
/// IProjectContent that will be used by the TestTreeView.
|
||||
/// </summary>
|
||||
protected override TestTreeView CreateTestTreeView() |
||||
{ |
||||
DummyParserServiceTestTreeView treeView = new DummyParserServiceTestTreeView(); |
||||
treeView.AddProjectContentForProject(projectContent); |
||||
return treeView; |
||||
} |
||||
|
||||
protected override Solution GetOpenSolution() |
||||
{ |
||||
getOpenSolutionCalled = true; |
||||
return openSolution; |
||||
} |
||||
|
||||
protected override bool IsParserLoadingSolution { |
||||
get { |
||||
loadSolutionProjectsThreadEndedHandled = addedLoadSolutionProjectsThreadEndedHandler; |
||||
isParserLoadingSolutionCalled = true; |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
protected override void OnAddedLoadSolutionProjectsThreadEndedHandler() |
||||
{ |
||||
addedLoadSolutionProjectsThreadEndedHandler = true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue