// // // // // $Revision$ // using ICSharpCode.Core; using ICSharpCode.CodeCoverage; using NUnit.Framework; using System; using System.IO; using System.Resources; namespace ICSharpCode.CodeCoverage.Tests { [TestFixture] public class MbUnitResultsTestFixture { 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); MbUnitResults results = new MbUnitResults(new StringReader(GetMbUnitResultsXml())); 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", "FooTest.Foo"}, {"Message", "Foo failed"} }); Assert.AreEqual(description, errorTask.Description); } string GetMbUnitResultsXml() { return "\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " Foo failed\r\n" + " nunit.framework\r\n" + " at NUnit.Framework.Assert.Fail(String message, Object[] args)\r\n" + " at NUnit.Framework.Assert.Fail(String message)\r\n" + " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + " \r\n" + ""; } } }