Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1068 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
20 changed files with 780 additions and 69 deletions
@ -0,0 +1,58 @@ |
|||||||
|
// <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 ICSharpCode.Core; |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage |
||||||
|
{ |
||||||
|
public enum CodeCoverageImageListIndex |
||||||
|
{ |
||||||
|
Module = 0, |
||||||
|
Namespace = 2, |
||||||
|
Class = 4, |
||||||
|
Method = 6, |
||||||
|
MethodWithZeroCoverage = 7 |
||||||
|
} |
||||||
|
|
||||||
|
public class CodeCoverageImageList |
||||||
|
{ |
||||||
|
static ImageList imageList; |
||||||
|
|
||||||
|
CodeCoverageImageList() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public static ImageList ImageList { |
||||||
|
get { |
||||||
|
if (imageList == null) { |
||||||
|
GetImageList(); |
||||||
|
} |
||||||
|
return imageList; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void GetImageList() |
||||||
|
{ |
||||||
|
imageList = new ImageList(); |
||||||
|
imageList.ColorDepth = ColorDepth.Depth32Bit; |
||||||
|
|
||||||
|
AddBitmap(ResourceService.GetBitmap("Icons.16x16.Library"), 0.2f); |
||||||
|
AddBitmap(ResourceService.GetBitmap("Icons.16x16.NameSpace"), 0.4f); |
||||||
|
AddBitmap(ResourceService.GetBitmap("Icons.16x16.Class"), 0.15f); |
||||||
|
AddBitmap(ResourceService.GetBitmap("Icons.16x16.Method"), 0.2f); |
||||||
|
} |
||||||
|
|
||||||
|
static void AddBitmap(Bitmap bitmap, float brightness) |
||||||
|
{ |
||||||
|
imageList.Images.Add(bitmap); |
||||||
|
imageList.Images.Add(GrayScaleBitmap.FromBitmap(bitmap, brightness)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,97 @@ |
|||||||
|
// <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.Drawing; |
||||||
|
using System.Drawing.Imaging; |
||||||
|
using System.IO; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage |
||||||
|
{ |
||||||
|
public class GrayScaleBitmap |
||||||
|
{ |
||||||
|
const int ColorMatrixSize = 5; |
||||||
|
|
||||||
|
GrayScaleBitmap() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a bitmap to a grayscale bitmap.
|
||||||
|
/// </summary>
|
||||||
|
public static Bitmap FromBitmap(Bitmap bitmap) |
||||||
|
{ |
||||||
|
return FromBitmap(bitmap, GetGrayScaleColorMatrix()); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a grayscale bitmap and also changes its brightness.
|
||||||
|
/// </summary>
|
||||||
|
public static Bitmap FromBitmap(Bitmap bitmap, float brightness) |
||||||
|
{ |
||||||
|
ColorMatrix m = new ColorMatrix(); |
||||||
|
m.Matrix00 = 1; |
||||||
|
m.Matrix11 = 1; |
||||||
|
m.Matrix22 = 1; |
||||||
|
m.Matrix33 = 1; |
||||||
|
m.Matrix40 = brightness; |
||||||
|
m.Matrix41 = brightness; |
||||||
|
m.Matrix42 = brightness; |
||||||
|
m.Matrix44 = 1; |
||||||
|
|
||||||
|
return FromBitmap(bitmap, Multiply(m, GetGrayScaleColorMatrix())); |
||||||
|
} |
||||||
|
|
||||||
|
static Bitmap FromBitmap(Bitmap bitmap, ColorMatrix colorMatrix) |
||||||
|
{ |
||||||
|
ImageAttributes imageAttributes = new ImageAttributes(); |
||||||
|
imageAttributes.SetColorMatrix(colorMatrix); |
||||||
|
Bitmap grayBitmap = new Bitmap(bitmap); |
||||||
|
using (Graphics g = Graphics.FromImage(grayBitmap)) { |
||||||
|
g.DrawImage(grayBitmap, new Rectangle(0, 0, grayBitmap.Width, grayBitmap.Height), 0, 0, grayBitmap.Width, grayBitmap.Height, GraphicsUnit.Pixel, imageAttributes); |
||||||
|
return grayBitmap; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static ColorMatrix GetGrayScaleColorMatrix() |
||||||
|
{ |
||||||
|
ColorMatrix m = new ColorMatrix(); |
||||||
|
m.Matrix00 = 0.299f; |
||||||
|
m.Matrix01 = 0.299f; |
||||||
|
m.Matrix02 = 0.299f; |
||||||
|
m.Matrix10 = 0.587f; |
||||||
|
m.Matrix11 = 0.587f; |
||||||
|
m.Matrix12 = 0.587f; |
||||||
|
m.Matrix20 = 0.114f; |
||||||
|
m.Matrix21 = 0.114f; |
||||||
|
m.Matrix22 = 0.114f; |
||||||
|
m.Matrix33 = 1; |
||||||
|
m.Matrix44 = 1; |
||||||
|
return m; |
||||||
|
} |
||||||
|
|
||||||
|
static ColorMatrix Multiply(ColorMatrix m, ColorMatrix n) |
||||||
|
{ |
||||||
|
ColorMatrix colorMatrix = new ColorMatrix(); |
||||||
|
float[] column = new float[ColorMatrixSize]; |
||||||
|
for (int j = 0; j < ColorMatrixSize; ++j) { |
||||||
|
for (int k = 0; k < ColorMatrixSize; ++k) { |
||||||
|
column[k] = m[k, j]; |
||||||
|
} |
||||||
|
for (int i = 0; i < ColorMatrixSize; ++i) { |
||||||
|
float s = 0; |
||||||
|
for (int k = 0; k < ColorMatrixSize; ++k) { |
||||||
|
s += n[i, k] * column[k]; |
||||||
|
} |
||||||
|
colorMatrix[i, j] = s; |
||||||
|
} |
||||||
|
} |
||||||
|
return colorMatrix; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,113 @@ |
|||||||
|
// <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 ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
using System.Xml; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Reads the NUnit results file.
|
||||||
|
/// </summary>
|
||||||
|
public class NUnitResults |
||||||
|
{ |
||||||
|
static readonly string TestCaseElementName = "test-case"; |
||||||
|
static readonly string MessageElementName = "message"; |
||||||
|
static readonly string StackTraceElementName= "stack-trace"; |
||||||
|
|
||||||
|
List<Task> tasks = new List<Task>(); |
||||||
|
|
||||||
|
public NUnitResults(string fileName) : this(new StreamReader(fileName, true)) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public NUnitResults(XmlTextReader reader) |
||||||
|
{ |
||||||
|
ReadResults(reader); |
||||||
|
} |
||||||
|
|
||||||
|
public NUnitResults(TextReader reader) : this(new XmlTextReader(reader)) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public List<Task> Tasks { |
||||||
|
get { |
||||||
|
return tasks; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ReadResults(XmlTextReader reader) |
||||||
|
{ |
||||||
|
using (reader) { |
||||||
|
while (reader.Read()) { |
||||||
|
if (reader.NodeType == XmlNodeType.Element) { |
||||||
|
if (IsTestCaseFailureElement(reader)) { |
||||||
|
ReadErrorTask(reader); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool IsTestCaseFailureElement(XmlReader reader) |
||||||
|
{ |
||||||
|
if (reader.Name == TestCaseElementName) { |
||||||
|
string success = reader.GetAttribute("success"); |
||||||
|
if (success == "False") { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
void ReadErrorTask(XmlReader reader) |
||||||
|
{ |
||||||
|
string testCase = reader.GetAttribute("name"); |
||||||
|
string message = String.Empty; |
||||||
|
|
||||||
|
while (reader.Read()) { |
||||||
|
if (reader.NodeType == XmlNodeType.Element) { |
||||||
|
if (reader.Name == MessageElementName) { |
||||||
|
message = reader.ReadElementString(); |
||||||
|
} else if (reader.Name == StackTraceElementName) { |
||||||
|
string stackTrace = reader.ReadElementString(); |
||||||
|
AddTask(GetDescription(testCase, message), stackTrace); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets task error description.
|
||||||
|
/// </summary>
|
||||||
|
string GetDescription(string testCase, string message) |
||||||
|
{ |
||||||
|
return StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||||
|
{"TestCase", testCase}, |
||||||
|
{"Message", message} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
void AddTask(string description, string stackTrace) |
||||||
|
{ |
||||||
|
FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(stackTrace, true); |
||||||
|
if (lineRef != null) { |
||||||
|
Task task = new Task(Path.GetFullPath(lineRef.FileName), |
||||||
|
description, |
||||||
|
lineRef.Column, |
||||||
|
lineRef.Line, |
||||||
|
TaskType.Error); |
||||||
|
tasks.Add(task); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,81 @@ |
|||||||
|
// <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 ICSharpCode.CodeCoverage; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class DisplayItemTestFixture |
||||||
|
{ |
||||||
|
CodeCoverageDisplayItem displayItem; |
||||||
|
string itemName = "Code Covered"; |
||||||
|
string backColorPropertyName = "BackColor"; |
||||||
|
Color backColor = Color.Lime; |
||||||
|
string foreColorPropertyName = "ForeColor"; |
||||||
|
Color foreColor = Color.Blue; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
displayItem = new CodeCoverageDisplayItem(itemName, backColorPropertyName, backColor, foreColorPropertyName, foreColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DisplayItemToString() |
||||||
|
{ |
||||||
|
Assert.AreEqual(itemName, displayItem.ToString()); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void HasChanged() |
||||||
|
{ |
||||||
|
Assert.IsFalse(displayItem.HasChanged); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void BackColor() |
||||||
|
{ |
||||||
|
Assert.AreEqual(backColor, displayItem.BackColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void BackColorPropertyName() |
||||||
|
{ |
||||||
|
Assert.AreEqual(backColorPropertyName, displayItem.BackColorPropertyName); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ForeColor() |
||||||
|
{ |
||||||
|
Assert.AreEqual(foreColor, displayItem.ForeColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ForeColorPropertyName() |
||||||
|
{ |
||||||
|
Assert.AreEqual(foreColorPropertyName, displayItem.ForeColorPropertyName); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ChangeBackColor() |
||||||
|
{ |
||||||
|
displayItem.BackColor = Color.Red; |
||||||
|
Assert.IsTrue(displayItem.HasChanged); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ChangeForeColor() |
||||||
|
{ |
||||||
|
displayItem.ForeColor = Color.Yellow; |
||||||
|
Assert.IsTrue(displayItem.HasChanged); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
// <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 ICSharpCode.CodeCoverage; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class InvalidSequencePointDataTestFixture |
||||||
|
{ |
||||||
|
CodeCoverageResults results; |
||||||
|
CodeCoverageSequencePoint invalidVisitCountSequencePoint; |
||||||
|
CodeCoverageSequencePoint invalidLineCountSequencePoint; |
||||||
|
CodeCoverageSequencePoint invalidColumnCountSequencePoint; |
||||||
|
|
||||||
|
[TestFixtureSetUp] |
||||||
|
public void SetUpFixture() |
||||||
|
{ |
||||||
|
string xml = "<coverage>\r\n" + |
||||||
|
"\t<module name=\"C:\\Projects\\Foo.Tests\\bin\\Debug\\Foo.Tests.dll\" assembly=\"Foo.Tests\">\r\n" + |
||||||
|
"\t\t<method name=\"InvalidVisitCount\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||||
|
"\t\t\t<seqpnt visitcount=\"a\" line=\"10\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" + |
||||||
|
"\t\t</method>\r\n" + |
||||||
|
"\t\t<method name=\"InvalidLine\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||||
|
"\t\t\t<seqpnt visitcount=\"2\" line=\"b\" column=\"3\" endline=\"20\" endcolumn=\"4\" document=\"c:\\Projects\\Foo\\SimpleTestFixture.cs\" />\r\n" + |
||||||
|
"\t\t</method>\r\n" + |
||||||
|
"\t\t<method name=\"InvalidColumn\" class=\"Foo.Tests.FooTestFixture\">\r\n" + |
||||||
|
"\t\t\t<seqpnt visitcount=\"1\" line=\"20\" column=\"c\" endline=\"d\" endcolumn=\"e\" document=\"c:\\Projects\\Foo\\SimpleTestFixture.cs\" />\r\n" + |
||||||
|
"\t\t</method>\r\n" + |
||||||
|
"\t</module>\r\n" + |
||||||
|
"</coverage>"; |
||||||
|
|
||||||
|
results = new CodeCoverageResults(new StringReader(xml)); |
||||||
|
invalidVisitCountSequencePoint = results.Modules[0].Methods[0].SequencePoints[0]; |
||||||
|
invalidLineCountSequencePoint = results.Modules[0].Methods[1].SequencePoints[0]; |
||||||
|
invalidColumnCountSequencePoint = results.Modules[0].Methods[2].SequencePoints[0]; |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void InvalidVisitCount() |
||||||
|
{ |
||||||
|
Assert.AreEqual(0, invalidVisitCountSequencePoint.VisitCount, "Should be set to zero since it is invalid."); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void InvalidLineCount() |
||||||
|
{ |
||||||
|
Assert.AreEqual(0, invalidLineCountSequencePoint.Line, "Should be set to zero since it is invalid."); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void InvalidColumnCount() |
||||||
|
{ |
||||||
|
Assert.AreEqual(0, invalidColumnCountSequencePoint.Column, "Should be set to zero since it is invalid."); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
// <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 ICSharpCode.CodeCoverage; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage.Tests |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Checks that the CodeCoverageMethod class can handle a class name
|
||||||
|
/// that has no namespace.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture] |
||||||
|
public class MethodHasNoNamespaceTestFixture |
||||||
|
{ |
||||||
|
CodeCoverageMethod method; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
string methodName = "Foo"; |
||||||
|
string className = "Foo"; |
||||||
|
|
||||||
|
method = new CodeCoverageMethod(methodName, className); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ClassName() |
||||||
|
{ |
||||||
|
Assert.AreEqual("Foo", method.ClassName); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void MethodNamespace() |
||||||
|
{ |
||||||
|
Assert.AreEqual(String.Empty, method.ClassNamespace); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,99 @@ |
|||||||
|
// <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 ICSharpCode.Core; |
||||||
|
using ICSharpCode.CodeCoverage; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Resources; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class NUnitResultsTestFixture |
||||||
|
{ |
||||||
|
Task errorTask; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
// Add NUnitPad TestFailedMessage string resource since this resource
|
||||||
|
// contains a format string that has parameters that are otherwise not
|
||||||
|
// set.
|
||||||
|
ResourceManager resourceManager = new ResourceManager("ICSharpCode.CodeCoverage.Tests.Strings", GetType().Assembly); |
||||||
|
ResourceService.RegisterNeutralStrings(resourceManager); |
||||||
|
|
||||||
|
NUnitResults results = new NUnitResults(new StringReader(GetNUnitResultsXml())); |
||||||
|
errorTask = results.Tasks[0]; |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsErrorTask() |
||||||
|
{ |
||||||
|
Assert.AreEqual(TaskType.Error, errorTask.TaskType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorTaskFileName() |
||||||
|
{ |
||||||
|
Assert.IsTrue(FileUtility.IsEqualFileName(@"c:\test\NunitFoo\NunitFoo.Tests\FooTest.cs", errorTask.FileName)); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorTaskLine() |
||||||
|
{ |
||||||
|
Assert.AreEqual(21, errorTask.Line); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ErrorTaskColumn() |
||||||
|
{ |
||||||
|
Assert.AreEqual(0, errorTask.Column); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void TaskDescription() |
||||||
|
{ |
||||||
|
string description = StringParser.Parse("${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}", new string[,] { |
||||||
|
{"TestCase", "NunitFoo.Tests.FooTest.Foo"}, |
||||||
|
{"Message", "Foo failed"} |
||||||
|
}); |
||||||
|
|
||||||
|
Assert.AreEqual(description, errorTask.Description); |
||||||
|
} |
||||||
|
|
||||||
|
string GetNUnitResultsXml() |
||||||
|
{ |
||||||
|
return "<test-results name=\"C:\\test\\NunitFoo\\NunitFoo.Tests\\bin\\Debug\\NunitFoo.Tests.dll\" total=\"2\" failures=\"1\" not-run=\"0\" date=\"2006-01-31\" time=\"01:18:33\">\r\n" + |
||||||
|
" <test-suite name=\"C:\\test\\NunitFoo\\NunitFoo.Tests\\bin\\Debug\\NunitFoo.Tests.dll\" success=\"False\" time=\"0.040\" asserts=\"0\">\r\n" + |
||||||
|
" <results>\r\n" + |
||||||
|
" <test-suite name=\"NunitFoo\" success=\"False\" time=\"0.040\" asserts=\"0\">\r\n" + |
||||||
|
" <results>\r\n" + |
||||||
|
" <test-suite name=\"Tests\" success=\"False\" time=\"0.040\" asserts=\"0\">\r\n" + |
||||||
|
" <results>\r\n" + |
||||||
|
" <test-suite name=\"FooTest\" success=\"False\" time=\"0.030\" asserts=\"0\">\r\n" + |
||||||
|
" <results>\r\n" + |
||||||
|
" <test-case name=\"NunitFoo.Tests.FooTest.Foo\" executed=\"True\" success=\"False\" time=\"0.010\" asserts=\"0\">\r\n" + |
||||||
|
" <failure>\r\n" + |
||||||
|
" <message><![CDATA[Foo failed]]></message>\r\n" + |
||||||
|
" <stack-trace><![CDATA[ at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n" + |
||||||
|
"]]></stack-trace>\r\n" + |
||||||
|
" </failure>\r\n" + |
||||||
|
" </test-case>\r\n" + |
||||||
|
" </results>\r\n" + |
||||||
|
" </test-suite>\r\n" + |
||||||
|
" </results>\r\n" + |
||||||
|
" </test-suite>\r\n" + |
||||||
|
" </results>\r\n" + |
||||||
|
" </test-suite>\r\n" + |
||||||
|
" </results>\r\n" + |
||||||
|
" </test-suite>\r\n" + |
||||||
|
"</test-results>"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,107 @@ |
|||||||
|
// <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 ICSharpCode.SharpDevelop.Gui; |
||||||
|
using ICSharpCode.CodeCoverage; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace ICSharpCode.CodeCoverage.Tests |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class ZeroCodeCoverageTreeViewTestFixture |
||||||
|
{ |
||||||
|
TreeNodeCollection nodes; |
||||||
|
CodeCoverageModuleTreeNode fooModuleNode; |
||||||
|
CodeCoverageClassTreeNode fooTestFixtureTreeNode; |
||||||
|
CodeCoverageMethodTreeNode fooTestMethodTreeNode; |
||||||
|
CodeCoverageNamespaceTreeNode fooNamespaceTreeNode; |
||||||
|
CodeCoverageNamespaceTreeNode fooTestsNamespaceTreeNode; |
||||||
|
|
||||||
|
[SetUp] |
||||||
|
public void Init() |
||||||
|
{ |
||||||
|
List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); |
||||||
|
CodeCoverageModule fooModule = new CodeCoverageModule("Foo.Tests"); |
||||||
|
CodeCoverageMethod fooTestMethod = new CodeCoverageMethod("FooTest", "Foo.Tests.FooTestFixture"); |
||||||
|
fooTestMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 0, 1, 0, 2, 1)); |
||||||
|
fooTestMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 0, 2, 2, 3, 4)); |
||||||
|
|
||||||
|
fooModule.Methods.Add(fooTestMethod); |
||||||
|
|
||||||
|
modules.Add(fooModule); |
||||||
|
|
||||||
|
using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) { |
||||||
|
treeView.AddModules(modules); |
||||||
|
treeView.ExpandAll(); |
||||||
|
nodes = treeView.Nodes; |
||||||
|
} |
||||||
|
|
||||||
|
fooModuleNode = (CodeCoverageModuleTreeNode)nodes[0]; |
||||||
|
fooNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0]; |
||||||
|
fooTestsNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooNamespaceTreeNode.Nodes[0]; |
||||||
|
|
||||||
|
fooTestFixtureTreeNode = (CodeCoverageClassTreeNode)fooTestsNamespaceTreeNode.Nodes[0]; |
||||||
|
fooTestMethodTreeNode = (CodeCoverageMethodTreeNode)fooTestFixtureTreeNode.Nodes[0]; |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooModuleTreeNodeText() |
||||||
|
{ |
||||||
|
Assert.AreEqual("Foo.Tests (0%)", fooModuleNode.Text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooModuleTreeNodeForeColor() |
||||||
|
{ |
||||||
|
Assert.AreEqual(CodeCoverageTreeNode.ZeroCoverageTextColor, fooModuleNode.ForeColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooMethodTreeNodeText() |
||||||
|
{ |
||||||
|
Assert.AreEqual("FooTest (0%)", fooTestMethodTreeNode.Text); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooMethodTreeNodeForeColor() |
||||||
|
{ |
||||||
|
Assert.AreEqual(CodeCoverageTreeNode.ZeroCoverageTextColor, fooTestMethodTreeNode.ForeColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooTestFixtureTreeNodeForeColor() |
||||||
|
{ |
||||||
|
Assert.AreEqual(CodeCoverageTreeNode.ZeroCoverageTextColor, fooTestFixtureTreeNode.ForeColor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void FooMethodTreeNodeImageIndex() |
||||||
|
{ |
||||||
|
Assert.AreEqual(CodeCoverageImageListIndex.MethodWithZeroCoverage, (CodeCoverageImageListIndex)(fooTestMethodTreeNode.ImageIndex)); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ChangeFooMethodFixtureVisitCount() |
||||||
|
{ |
||||||
|
fooTestMethodTreeNode.VisitedCount = 1; |
||||||
|
Assert.AreEqual(CodeCoverageImageListIndex.Method, (CodeCoverageImageListIndex)(fooTestMethodTreeNode.ImageIndex)); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ChangeFooMethodFixtureTotalVisitsCount() |
||||||
|
{ |
||||||
|
fooTestMethodTreeNode.NotVisitedCount = 0; |
||||||
|
fooTestMethodTreeNode.VisitedCount = 2; |
||||||
|
Assert.AreEqual(Color.Empty, fooTestMethodTreeNode.ForeColor); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue