Browse Source
- Unit Tests window changes: It now has an All Tests root node when multiple test projects exist in a solution. Added a toolbar button and menu item to run all the tests in the solution independent of the currently selected test. Added a run with code coverage toolbar button. - Fixed SD2-1123. Code coverage vist count list view is now sortable by column. - Fixed finding generic code-completion members by their Reflection name - fixes problems with Code analysis line numbers not showing for generic classes. - Fixed SD2-1275: Searching using an invalid regex shows search in progress dialog - The LocalizedStringFile property in a WiX project is no longer escaped when the project is saved after making changes in the Application tab of the project options. - Removed Run All Tests context menu item from Unit Tests window. Code coverage window opened after all tests have been run with code coverage and there were no test failures. No longer using a static NCover runner which was raising events in two RunTestWithCodeCoverageCommand instances (toolbar, context menu) and causing one to try to read a test results file which no longer existed. - Fixed SD2-1252: Don't steal file associations from Visual Studio - Fixed SD2-1286: Nested With statements result in stack overflow - Update to NSvn 1.0.0.2727 git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2333 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
50 changed files with 1294 additions and 390 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,36 +0,0 @@
@@ -1,36 +0,0 @@
|
||||
// <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; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Single NCover runner that is used by all commands.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
public class NCoverRunnerSingleton |
||||
{ |
||||
static NCoverRunner runner; |
||||
|
||||
NCoverRunnerSingleton() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="NCoverRunner"/> instance.
|
||||
/// </summary>
|
||||
public static NCoverRunner Runner { |
||||
get { |
||||
if (runner == null) { |
||||
runner = new NCoverRunner(); |
||||
} |
||||
return runner; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
// <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.Collections; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.CodeCoverage |
||||
{ |
||||
/// <summary>
|
||||
/// Sorts the list view that contains code coverage sequence
|
||||
/// points.
|
||||
/// </summary>
|
||||
public class SequencePointListViewSorter : IComparer, IDisposable |
||||
{ |
||||
ListView listView; |
||||
int column = -1; |
||||
SortOrder sortOrder = SortOrder.None; |
||||
|
||||
const int VisitCountColumn = 0; |
||||
const int SequencePointLineColumn = 1; |
||||
const int SequencePointStartColumnColumn = 2; |
||||
const int SequencePointEndLineColumn = 3; |
||||
const int SequencePointEndColumnColumn = 4; |
||||
|
||||
public SequencePointListViewSorter(ListView listView) |
||||
{ |
||||
this.listView = listView; |
||||
listView.ListViewItemSorter = this; |
||||
listView.ColumnClick += ListViewColumnClick; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
if (listView != null) { |
||||
listView.ColumnClick -= ListViewColumnClick; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Compares two list view items and sorts them according
|
||||
/// to the currently sorted column.
|
||||
/// </summary>
|
||||
public int Compare(object x, object y) |
||||
{ |
||||
CodeCoverageSequencePoint lhs = null; |
||||
CodeCoverageSequencePoint rhs = null; |
||||
|
||||
ListViewItem item = x as ListViewItem; |
||||
if (item != null) { |
||||
lhs = item.Tag as CodeCoverageSequencePoint; |
||||
} |
||||
|
||||
item = y as ListViewItem; |
||||
if (item != null) { |
||||
rhs = item.Tag as CodeCoverageSequencePoint; |
||||
} |
||||
|
||||
if (lhs != null && rhs != null) { |
||||
return Compare(lhs, rhs); |
||||
} |
||||
return 0; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sorts the list view by the specified column.
|
||||
/// </summary>
|
||||
public void Sort(int column) |
||||
{ |
||||
if (this.column == column) { |
||||
ToggleSortOrder(); |
||||
} else { |
||||
sortOrder = SortOrder.Ascending; |
||||
} |
||||
this.column = column; |
||||
listView.Sort(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Compares two code coverage sequence points based on the
|
||||
/// currently sorted column and sort order.
|
||||
/// </summary>
|
||||
int Compare(CodeCoverageSequencePoint x, CodeCoverageSequencePoint y) |
||||
{ |
||||
int result = 0; |
||||
switch (column) { |
||||
case VisitCountColumn: |
||||
result = x.VisitCount - y.VisitCount; |
||||
break; |
||||
case SequencePointLineColumn: |
||||
result = x.Line - y.Line; |
||||
break; |
||||
case SequencePointStartColumnColumn: |
||||
result = x.Column - y.Column; |
||||
break; |
||||
case SequencePointEndLineColumn: |
||||
result = x.EndLine - y.EndLine; |
||||
break; |
||||
case SequencePointEndColumnColumn: |
||||
result = x.EndColumn - y.EndColumn; |
||||
break; |
||||
} |
||||
|
||||
// Sort by secondary sort column?
|
||||
if (result == 0 && column != SequencePointLineColumn) { |
||||
result = x.Line - y.Line; |
||||
} |
||||
|
||||
if (sortOrder == SortOrder.Descending) { |
||||
return -result; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Switches the sort order from ascending to descending
|
||||
/// and vice versa.
|
||||
/// </summary>
|
||||
void ToggleSortOrder() |
||||
{ |
||||
if (sortOrder == SortOrder.Ascending) { |
||||
sortOrder = SortOrder.Descending; |
||||
} else { |
||||
sortOrder = SortOrder.Ascending; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// User clicked a column header so sort that column.
|
||||
/// </summary>
|
||||
void ListViewColumnClick(object source, ColumnClickEventArgs e) |
||||
{ |
||||
Sort(e.Column); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,165 @@
@@ -0,0 +1,165 @@
|
||||
// <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.CodeCoverage; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.CodeCoverage.Tests |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the sorting of the list view that shows
|
||||
/// the code coverage sequence points (visit counts, etc).
|
||||
/// Here we are not actually using the real list view, but
|
||||
/// just a list view which has the same number of columns.
|
||||
/// Eventually the sorter class will be replaced in
|
||||
/// SharpDevelop 3.0 with the generic sorting classes.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ListViewSortingTestFixture |
||||
{ |
||||
ListView listView; |
||||
CodeCoverageSequencePoint firstSequencePoint; |
||||
CodeCoverageSequencePoint secondSequencePoint; |
||||
SequencePointListViewSorter sorter; |
||||
const int VisitCountColumn = 0; |
||||
const int SequencePointLineColumn = 1; |
||||
const int SequencePointStartColumnColumn = 2; |
||||
const int SequencePointEndLineColumn = 3; |
||||
const int SequencePointEndColumnColumn = 4; |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
listView = new ListView(); |
||||
sorter = new SequencePointListViewSorter(listView); |
||||
|
||||
listView.Columns.Add("Visit Count"); |
||||
listView.Columns.Add("Line"); |
||||
listView.Columns.Add("Column"); |
||||
listView.Columns.Add("End Line"); |
||||
listView.Columns.Add("End Column"); |
||||
|
||||
// Add first sequence point.
|
||||
firstSequencePoint = new CodeCoverageSequencePoint(String.Empty, 1, 5, 1, 5, 10); |
||||
ListViewItem item = new ListViewItem("First"); |
||||
item.Tag = firstSequencePoint; |
||||
listView.Items.Add(item); |
||||
|
||||
// Add second sequence point.
|
||||
secondSequencePoint = new CodeCoverageSequencePoint(String.Empty, 0, 10, 2, 10, 8); |
||||
item = new ListViewItem("Second"); |
||||
item.Tag = secondSequencePoint; |
||||
listView.Items.Add(item); |
||||
|
||||
// Need to create the control's handle otherwise
|
||||
// the list view will not sort.
|
||||
listView.CreateControl(); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
listView.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void InitialOrderSameAsOrderAdded() |
||||
{ |
||||
Assert.AreSame(firstSequencePoint, listView.Items[0].Tag); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[1].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortVisitCountColumn() |
||||
{ |
||||
sorter.Sort(VisitCountColumn); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortVisitCountColumnTwice() |
||||
{ |
||||
sorter.Sort(VisitCountColumn); |
||||
sorter.Sort(VisitCountColumn); |
||||
Assert.AreSame(firstSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortLineColumnTwice() |
||||
{ |
||||
sorter.Sort(SequencePointLineColumn); |
||||
sorter.Sort(SequencePointLineColumn); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortStartColumnTwice() |
||||
{ |
||||
sorter.Sort(SequencePointStartColumnColumn); |
||||
sorter.Sort(SequencePointStartColumnColumn); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortEndLineTwice() |
||||
{ |
||||
sorter.Sort(SequencePointEndLineColumn); |
||||
sorter.Sort(SequencePointEndLineColumn); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void SortEndColumn() |
||||
{ |
||||
sorter.Sort(SequencePointEndColumnColumn); |
||||
Assert.AreSame(secondSequencePoint, listView.Items[0].Tag); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompareNulls() |
||||
{ |
||||
Assert.AreEqual(0, sorter.Compare(null, null)); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompareNullRhs() |
||||
{ |
||||
Assert.AreEqual(0, sorter.Compare(null, new ListViewItem())); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompareTwoListViewItemsWithNoTags() |
||||
{ |
||||
sorter.Sort(VisitCountColumn); |
||||
Assert.AreEqual(0, sorter.Compare(new ListViewItem(), new ListViewItem())); |
||||
} |
||||
|
||||
[Test] |
||||
public void CompareRhsListViewItemWithNoTag() |
||||
{ |
||||
sorter.Sort(VisitCountColumn); |
||||
Assert.AreEqual(0, sorter.Compare(listView.Items[0], new ListViewItem())); |
||||
} |
||||
|
||||
[Test] |
||||
public void SecondarySortByLineWhenVisitCountSame() |
||||
{ |
||||
sorter.Sort(VisitCountColumn); |
||||
CodeCoverageSequencePoint pt1 = new CodeCoverageSequencePoint(String.Empty, 0, 1, 0, 0, 0); |
||||
CodeCoverageSequencePoint pt2 = new CodeCoverageSequencePoint(String.Empty, 0, 2, 0, 0, 0); |
||||
|
||||
ListViewItem item1 = new ListViewItem(); |
||||
item1.Tag = pt1; |
||||
ListViewItem item2 = new ListViewItem(); |
||||
item2.Tag = pt2; |
||||
|
||||
Assert.AreEqual(-1, sorter.Compare(item1, item2)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
namespace ICSharpCode.FiletypeRegisterer |
||||
{ |
||||
partial class RegisterFiletypesPanel |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the control.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.captionLabel = new System.Windows.Forms.Label(); |
||||
this.fileTypesListBox = new System.Windows.Forms.CheckedListBox(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// captionLabel
|
||||
//
|
||||
this.captionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.captionLabel.Location = new System.Drawing.Point(3, 0); |
||||
this.captionLabel.Name = "captionLabel"; |
||||
this.captionLabel.Size = new System.Drawing.Size(328, 23); |
||||
this.captionLabel.TabIndex = 0; |
||||
this.captionLabel.Text = "${res:ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.RegisterFiletypesPanel.Ca" + |
||||
"ptionLabel}"; |
||||
//
|
||||
// fileTypesListBox
|
||||
//
|
||||
this.fileTypesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
||||
| System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.fileTypesListBox.IntegralHeight = false; |
||||
this.fileTypesListBox.Location = new System.Drawing.Point(3, 26); |
||||
this.fileTypesListBox.Name = "fileTypesListBox"; |
||||
this.fileTypesListBox.Size = new System.Drawing.Size(328, 299); |
||||
this.fileTypesListBox.TabIndex = 1; |
||||
//
|
||||
// RegisterFiletypesPanel
|
||||
//
|
||||
this.Controls.Add(this.fileTypesListBox); |
||||
this.Controls.Add(this.captionLabel); |
||||
this.Name = "RegisterFiletypesPanel"; |
||||
this.Size = new System.Drawing.Size(334, 328); |
||||
this.ResumeLayout(false); |
||||
} |
||||
private System.Windows.Forms.CheckedListBox fileTypesListBox; |
||||
private System.Windows.Forms.Label captionLabel; |
||||
} |
||||
} |
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
// <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 ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.UnitTesting |
||||
{ |
||||
/// <summary>
|
||||
/// All Tests root tree node that is added to the test tree when the
|
||||
/// solution has multiple test projects.
|
||||
/// </summary>
|
||||
public class AllTestsTreeNode : TestTreeNode |
||||
{ |
||||
public AllTestsTreeNode() |
||||
: base(null, StringParser.Parse("${res:ICSharpCode.UnitTesting.AllTestsTreeNode.Text}")) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raised when the all tests tree node is disposed.
|
||||
/// </summary>
|
||||
public event EventHandler Disposed; |
||||
|
||||
/// <summary>
|
||||
/// Disposes this tree node.
|
||||
/// </summary>
|
||||
public override void Dispose() |
||||
{ |
||||
base.Dispose(); |
||||
if (Disposed != null) { |
||||
Disposed(this, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a new project node as a child of the All Tests node.
|
||||
/// </summary>
|
||||
public void AddProjectNode(TestProjectTreeNode node) |
||||
{ |
||||
node.AddTo(this); |
||||
node.ImageIndexChanged += TestProjectTreeNodeImageIndexChanged; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the project node.
|
||||
/// </summary>
|
||||
public void RemoveProjectNode(TestProjectTreeNode node) |
||||
{ |
||||
if (Nodes.Contains(node)) { |
||||
node.ImageIndexChanged -= TestProjectTreeNodeImageIndexChanged; |
||||
node.Remove(); |
||||
} |
||||
} |
||||
|
||||
void TestProjectTreeNodeImageIndexChanged(object source, EventArgs e) |
||||
{ |
||||
UpdateImageListIndex(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the All Tests image index based on the current image
|
||||
/// indexes of the child project tree nodes.
|
||||
/// </summary>
|
||||
void UpdateImageListIndex() |
||||
{ |
||||
int ignored = 0; |
||||
int failed = 0; |
||||
int passed = 0; |
||||
int notRun = 0; |
||||
int total = Nodes.Count; |
||||
|
||||
foreach (TestProjectTreeNode projectNode in Nodes) { |
||||
switch (projectNode.ImageIndex) { |
||||
case (int)TestTreeViewImageListIndex.TestFailed: |
||||
failed++; |
||||
break; |
||||
case (int)TestTreeViewImageListIndex.TestPassed: |
||||
passed++; |
||||
break; |
||||
case (int)TestTreeViewImageListIndex.TestIgnored: |
||||
ignored++; |
||||
break; |
||||
default: // Not run.
|
||||
notRun++; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
// Update the image index based on the test project results.
|
||||
if (failed > 0) { |
||||
UpdateImageListIndex(TestResultType.Failure); |
||||
} else if (ignored > 0) { |
||||
UpdateImageListIndex(TestResultType.Ignored); |
||||
} else if (passed > 0 && notRun == 0) { |
||||
UpdateImageListIndex(TestResultType.Success); |
||||
} else { |
||||
UpdateImageListIndex(TestResultType.None); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,210 @@
@@ -0,0 +1,210 @@
|
||||
// <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 ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using UnitTesting.Tests.Utils; |
||||
|
||||
namespace UnitTesting.Tests.Tree |
||||
{ |
||||
/// <summary>
|
||||
/// When there are multiple test projects in a solution then the
|
||||
/// test tree should have an All Tests root node.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class MultipleTestProjectsTestFixture |
||||
{ |
||||
DummyParserServiceTestTreeView treeView; |
||||
MockCSharpProject firstProject; |
||||
MockCSharpProject secondProject; |
||||
AllTestsTreeNode allTestsTreeNode; |
||||
TestProject firstTestProject; |
||||
TestProject secondTestProject; |
||||
Solution solution; |
||||
|
||||
[SetUp] |
||||
public void SetUp() |
||||
{ |
||||
treeView = new DummyParserServiceTestTreeView(); |
||||
|
||||
// Create a solution with two test projects.
|
||||
solution = new Solution(); |
||||
|
||||
// Create the first test project.
|
||||
firstProject = new MockCSharpProject(solution); |
||||
firstProject.Name = "FirstTestProject"; |
||||
ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(firstProject); |
||||
nunitFrameworkReferenceItem.Include = "NUnit.Framework"; |
||||
ProjectService.AddProjectItem(firstProject, nunitFrameworkReferenceItem); |
||||
|
||||
// Create the second test project.
|
||||
secondProject = new MockCSharpProject(solution); |
||||
secondProject.Name = "SecondTestProject"; |
||||
nunitFrameworkReferenceItem = new ReferenceProjectItem(secondProject); |
||||
nunitFrameworkReferenceItem.Include = "NUnit.Framework"; |
||||
ProjectService.AddProjectItem(secondProject, nunitFrameworkReferenceItem); |
||||
|
||||
// Add the projects to the solution.
|
||||
solution.Folders.Add(firstProject); |
||||
solution.Folders.Add(secondProject); |
||||
|
||||
// Create a dummy project content so the projects will be added
|
||||
// to the tree.
|
||||
treeView.ProjectContentForProject = new MockProjectContent(); |
||||
|
||||
// Add the solution to the tree.
|
||||
treeView.AddSolution(solution); |
||||
|
||||
allTestsTreeNode = treeView.Nodes[0] as AllTestsTreeNode; |
||||
firstTestProject = treeView.GetTestProject(firstProject); |
||||
secondTestProject = treeView.GetTestProject(secondProject); |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
treeView.Dispose(); |
||||
} |
||||
|
||||
[Test] |
||||
public void OneAllTestsRootNode() |
||||
{ |
||||
Assert.AreEqual(1, treeView.Nodes.Count); |
||||
} |
||||
|
||||
[Test] |
||||
public void RootNodeIsAllTestsNode() |
||||
{ |
||||
Assert.IsNotNull(allTestsTreeNode); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestsNodeText() |
||||
{ |
||||
Assert.AreEqual(StringParser.Parse("${res:ICSharpCode.UnitTesting.AllTestsTreeNode.Text}"), treeView.Nodes[0].Text); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetProjectsAfterClear() |
||||
{ |
||||
treeView.Clear(); |
||||
Assert.AreEqual(0, treeView.GetProjects().Length); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Tests that the All Tests node is removed when only one
|
||||
/// project remains.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void ProjectRemoved() |
||||
{ |
||||
treeView.RemoveProject(firstProject); |
||||
|
||||
Assert.AreEqual(1, treeView.GetProjects().Length); |
||||
Assert.IsInstanceOfType(typeof(TestProjectTreeNode), treeView.Nodes[0]); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Tests that the all test node has the correct image index.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void ProjectIgnoredTestResult() |
||||
{ |
||||
TestClass c = new TestClass(new MockClass("Tests.TestFixture")); |
||||
firstTestProject.TestClasses.Add(c); |
||||
c.Result = TestResultType.Ignored; |
||||
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestIgnored, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Tests that a removed project does not affect the image index of the
|
||||
/// All Tests root node.
|
||||
/// </summary>
|
||||
[Test] |
||||
public void IgnoredTestResultAfterProjectRemoved() |
||||
{ |
||||
// Add an extra project so when we remove one the All Tests node
|
||||
// is not removed.
|
||||
MockCSharpProject project = new MockCSharpProject(solution); |
||||
project.Name = "ThirdTestProject"; |
||||
ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); |
||||
nunitFrameworkReferenceItem.Include = "NUnit.Framework"; |
||||
ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); |
||||
|
||||
// Add the project into a dummy project node.
|
||||
TestProject testProject = new TestProject(project, new MockProjectContent()); |
||||
DerivedTestProjectTreeNode projectNode = new DerivedTestProjectTreeNode(testProject); |
||||
allTestsTreeNode.AddProjectNode(projectNode); |
||||
|
||||
// Remove an existing project.
|
||||
treeView.RemoveProject(project); |
||||
|
||||
// Modify the image index for the removed tree node.
|
||||
projectNode.CallUpdateImageListIndex(TestResultType.Ignored); |
||||
|
||||
// Image index of the all tests node should be unchanged.
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectFailedTestResult() |
||||
{ |
||||
TestClass c = new TestClass(new MockClass("Tests.TestFixture")); |
||||
firstTestProject.TestClasses.Add(c); |
||||
c.Result = TestResultType.Failure; |
||||
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestFailed, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectPassedTestResult() |
||||
{ |
||||
TestClass c = new TestClass(new MockClass("Tests.TestFixture")); |
||||
firstTestProject.TestClasses.Add(c); |
||||
c.Result = TestResultType.Success; |
||||
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestsNodeImageIndexReset() |
||||
{ |
||||
// Make one of the test projects pass so the all tests
|
||||
// node's image index is changed.
|
||||
ProjectPassedTestResult(); |
||||
|
||||
// Set the test class result back to not run.
|
||||
firstTestProject.TestClasses[0].Result = TestResultType.None; |
||||
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestNotRun, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
[Test] |
||||
public void AllTestProjectsPassed() |
||||
{ |
||||
TestClass c = new TestClass(new MockClass("Tests.TestFixture")); |
||||
firstTestProject.TestClasses.Add(c); |
||||
c.Result = TestResultType.Success; |
||||
|
||||
c = new TestClass(new MockClass("Tests.TestFixture")); |
||||
secondTestProject.TestClasses.Add(c); |
||||
c.Result = TestResultType.Success; |
||||
|
||||
Assert.AreEqual((int)TestTreeViewImageListIndex.TestPassed, allTestsTreeNode.ImageIndex); |
||||
} |
||||
|
||||
[Test] |
||||
public void CanClearSelection() |
||||
{ |
||||
Assert.IsFalse(treeView.CanClearSelection); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <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 ICSharpCode.UnitTesting; |
||||
|
||||
namespace UnitTesting.Tests.Utils |
||||
{ |
||||
/// <summary>
|
||||
/// Derived version of the TestProjectTreeNode class that
|
||||
/// allows us to call the UpdateImageListIndex method directly.
|
||||
/// </summary>
|
||||
public class DerivedTestProjectTreeNode : TestProjectTreeNode |
||||
{ |
||||
public DerivedTestProjectTreeNode(TestProject testProject) |
||||
: base(testProject) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Calls the base class's UpdateImageListIndex method.
|
||||
/// </summary>
|
||||
public void CallUpdateImageListIndex(TestResultType result) |
||||
{ |
||||
base.UpdateImageListIndex(result); |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue