Browse Source

Fix MSTest sample.

pull/297/head
Matt Ward 12 years ago
parent
commit
84ce627559
  1. 9
      samples/MSTest/MSTest.SharpDevelop.Tests/MSTest.SharpDevelop.Tests.csproj
  2. 438
      samples/MSTest/MSTest.SharpDevelop.Tests/MSTestFrameworkTests.cs
  3. 3
      samples/MSTest/MSTest.SharpDevelop.Tests/MSTestResultsTests.cs
  4. 2
      samples/MSTest/MSTest.SharpDevelop.sln
  5. 16
      samples/MSTest/MSTest.SharpDevelop/MSTest.SharpDevelop.csproj
  6. 24
      samples/MSTest/MSTest.SharpDevelop/MSTestApplication.cs
  7. 99
      samples/MSTest/MSTest.SharpDevelop/MSTestClass.cs
  8. 117
      samples/MSTest/MSTest.SharpDevelop/MSTestDebugger.cs
  9. 82
      samples/MSTest/MSTest.SharpDevelop/MSTestFramework.cs
  10. 72
      samples/MSTest/MSTest.SharpDevelop/MSTestMember.cs
  11. 60
      samples/MSTest/MSTest.SharpDevelop/MSTestMonitor.cs
  12. 2
      samples/MSTest/MSTest.SharpDevelop/MSTestOptions.cs
  13. 13
      samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml.cs
  14. 22
      samples/MSTest/MSTest.SharpDevelop/MSTestProcessRunnerContext.cs
  15. 129
      samples/MSTest/MSTest.SharpDevelop/MSTestProject.cs
  16. 13
      samples/MSTest/MSTest.SharpDevelop/MSTestResult.cs
  17. 9
      samples/MSTest/MSTest.SharpDevelop/MSTestResultsFileName.cs
  18. 118
      samples/MSTest/MSTest.SharpDevelop/MSTestRunner.cs

9
samples/MSTest/MSTest.SharpDevelop.Tests/MSTest.SharpDevelop.Tests.csproj

@ -7,8 +7,9 @@ @@ -7,8 +7,9 @@
<OutputType>Library</OutputType>
<RootNamespace>MSTest.SharpDevelop.Tests</RootNamespace>
<AssemblyName>MSTest.SharpDevelop.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
@ -33,12 +34,12 @@ @@ -33,12 +34,12 @@
<Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\src\Tools\NUnit\nunit.framework.dll</HintPath>
</Reference>

438
samples/MSTest/MSTest.SharpDevelop.Tests/MSTestFrameworkTests.cs

@ -43,9 +43,9 @@ namespace MSTest.SharpDevelop.Tests @@ -43,9 +43,9 @@ namespace MSTest.SharpDevelop.Tests
{
fakeProject
.Stub(project => project.Items)
.Return(new ReadOnlyCollection<ProjectItem>(projectItems));
.Return(new SimpleModelCollection<ProjectItem>(projectItems));
}
void AddFileAndReferenceToProject(string fileName, string reference)
{
var projectItems = new List<ProjectItem>();
@ -60,78 +60,78 @@ namespace MSTest.SharpDevelop.Tests @@ -60,78 +60,78 @@ namespace MSTest.SharpDevelop.Tests
AddReferencesToProject();
}
IClass CreateClassWithoutAnyAttributes()
{
IClass fakeClass = MockRepository.GenerateStub<IClass>();
AddAttributesToClass(fakeClass, new List<IAttribute>());
return fakeClass;
}
void AddAttributesToClass(IClass fakeClass, List<IAttribute> attributes)
{
fakeClass.Stub(c => c.Attributes).Return(attributes);
}
IClass CreateClassWithAttributes(params string[] attributeNames)
{
IClass fakeClass = MockRepository.GenerateStub<IClass>();
List<IAttribute> attributes = CreateAttributes(attributeNames);
AddAttributesToClass(fakeClass, attributes);
return fakeClass;
}
List<IAttribute> CreateAttributes(params string[] attributeNames)
{
return attributeNames.Select(name => CreateAttribute(name)).ToList();
}
IAttribute CreateAttribute(string name)
{
IReturnType returnType = MockRepository.GenerateStub<IReturnType>();
returnType.Stub(t => t.FullyQualifiedName).Return(name);
IAttribute attribute = MockRepository.GenerateStub<IAttribute>();
attribute.Stub(a => a.AttributeType).Return(returnType);
return attribute;
}
void MakeClassAbstract(IClass fakeClass)
{
fakeClass.Stub(c => c.IsAbstract).Return(true);
}
IMethod CreateMethodWithoutAnyAttributes()
{
IMethod fakeMethod = MockRepository.GenerateStub<IMethod>();
AddAttributesToMethod(fakeMethod, new List<IAttribute>());
return fakeMethod;
}
IMethod CreateMethodWithAttributes(params string[] attributeNames)
{
IMethod fakeMethod = MockRepository.GenerateStub<IMethod>();
List<IAttribute> attributes = CreateAttributes(attributeNames);
AddAttributesToMethod(fakeMethod, attributes);
return fakeMethod;
}
void AddAttributesToMethod(IMethod method, List<IAttribute> attributes)
{
method.Stub(m => m.Attributes).Return(attributes);
}
List<TestMember> GetTestMembersFor(IClass fakeClass)
{
return testFramework.GetTestMembersFor(fakeClass).ToList();
}
void AddMethodsToClass(IClass fakeClass, List<IMethod> methods)
{
fakeClass.Stub(c => c.Methods).Return(methods);
}
// IClass CreateClassWithoutAnyAttributes()
// {
// IClass fakeClass = MockRepository.GenerateStub<IClass>();
// AddAttributesToClass(fakeClass, new List<IAttribute>());
// return fakeClass;
// }
//
// void AddAttributesToClass(IClass fakeClass, List<IAttribute> attributes)
// {
// fakeClass.Stub(c => c.Attributes).Return(attributes);
// }
//
// IClass CreateClassWithAttributes(params string[] attributeNames)
// {
// IClass fakeClass = MockRepository.GenerateStub<IClass>();
//
// List<IAttribute> attributes = CreateAttributes(attributeNames);
//
// AddAttributesToClass(fakeClass, attributes);
//
// return fakeClass;
// }
//
// List<IAttribute> CreateAttributes(params string[] attributeNames)
// {
// return attributeNames.Select(name => CreateAttribute(name)).ToList();
// }
//
// IAttribute CreateAttribute(string name)
// {
// IReturnType returnType = MockRepository.GenerateStub<IReturnType>();
// returnType.Stub(t => t.FullyQualifiedName).Return(name);
//
// IAttribute attribute = MockRepository.GenerateStub<IAttribute>();
// attribute.Stub(a => a.AttributeType).Return(returnType);
// return attribute;
// }
//
// void MakeClassAbstract(IClass fakeClass)
// {
// fakeClass.Stub(c => c.IsAbstract).Return(true);
// }
//
// IMethod CreateMethodWithoutAnyAttributes()
// {
// IMethod fakeMethod = MockRepository.GenerateStub<IMethod>();
// AddAttributesToMethod(fakeMethod, new List<IAttribute>());
// return fakeMethod;
// }
//
// IMethod CreateMethodWithAttributes(params string[] attributeNames)
// {
// IMethod fakeMethod = MockRepository.GenerateStub<IMethod>();
// List<IAttribute> attributes = CreateAttributes(attributeNames);
// AddAttributesToMethod(fakeMethod, attributes);
// return fakeMethod;
// }
//
// void AddAttributesToMethod(IMethod method, List<IAttribute> attributes)
// {
// method.Stub(m => m.Attributes).Return(attributes);
// }
//
// List<TestMember> GetTestMembersFor(IClass fakeClass)
// {
// return testFramework.GetTestMembersFor(fakeClass).ToList();
// }
//
// void AddMethodsToClass(IClass fakeClass, List<IMethod> methods)
// {
// fakeClass.Stub(c => c.Methods).Return(methods);
// }
[Test]
public void IsTestProject_NullProject_ReturnsFalse()
@ -189,150 +189,150 @@ namespace MSTest.SharpDevelop.Tests @@ -189,150 +189,150 @@ namespace MSTest.SharpDevelop.Tests
Assert.IsTrue(result);
}
[Test]
public void IsTestClass_ClassHasNoAttributes_ReturnsFalse()
{
IClass fakeClass = CreateClassWithoutAnyAttributes();
bool result = testFramework.IsTestClass(fakeClass);
Assert.IsFalse(result);
}
[Test]
public void IsTestClass_ClassHasTestFixtureAttributeMissingAttributePart_ReturnsTrue()
{
IClass fakeClass = CreateClassWithAttributes("TestClass");
bool result = testFramework.IsTestClass(fakeClass);
Assert.IsTrue(result);
}
[Test]
public void IsTestClass_ClassHasTestClassAttributeAndIsAbstract_ReturnsFalse()
{
IClass fakeClass = CreateClassWithAttributes("TestClass");
MakeClassAbstract(fakeClass);
bool result = testFramework.IsTestClass(fakeClass);
Assert.IsFalse(result);
}
[Test]
public void IsTestClass_ClassHasTestClassAttributeIncludingAttributePart_ReturnsTrue()
{
IClass fakeClass = CreateClassWithAttributes("TestClassAttribute");
bool result = testFramework.IsTestClass(fakeClass);
Assert.IsTrue(result);
}
[Test]
public void IsTestClass_ClassHasFullyQualifiedMSTestClassAttribute_ReturnsTrue()
{
IClass fakeClass = CreateClassWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute");
bool result = testFramework.IsTestClass(fakeClass);
Assert.IsTrue(result);
}
[Test]
public void IsTestClass_ClassIsNull_ReturnsFalse()
{
bool result = testFramework.IsTestClass(null);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_MethodHasNoAttributes_ReturnsFalse()
{
IMethod method = CreateMethodWithoutAnyAttributes();
bool result = testFramework.IsTestMember(method);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_MethodHasTestMethodAttributeWithoutAttributePart_ReturnsTrue()
{
IMethod method = CreateMethodWithAttributes("TestMethod");
bool result = testFramework.IsTestMember(method);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodHasTestMethodAttributeAttribute_ReturnsTrue()
{
IMethod method = CreateMethodWithAttributes("TestMethodAttribute");
bool result = testFramework.IsTestMember(method);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodHasFullyQualifiedMSTestTestMethodAttribute_ReturnsTrue()
{
IMethod method = CreateMethodWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute");
bool result = testFramework.IsTestMember(method);
Assert.IsTrue(result);
}
[Test]
public void IsTestMember_MethodIsNull_ReturnsFalse()
{
bool result = testFramework.IsTestMember(null);
Assert.IsFalse(result);
}
[Test]
public void IsTestMember_MemberNotMethod_ReturnsFalse()
{
IMember member = MockRepository.GenerateStub<IMember>();
bool result = testFramework.IsTestMember(member);
Assert.IsFalse(result);
}
[Test]
public void GetTestMembersFor_ClassHasNoMethods_ReturnsFalse()
{
IClass fakeClass = CreateClassWithAttributes("TestClass");
AddMethodsToClass(fakeClass, new List<IMethod>());
List<TestMember> testMembers = GetTestMembersFor(fakeClass);
Assert.AreEqual(0, testMembers.Count);
}
[Test]
public void GetTestMembersFor_ClassHasTwoMethodsAndSecondOneIsTestMethod_ReturnsSecondTestMethodOnly()
{
IClass fakeClass = CreateClassWithAttributes("TestClass");
var methods = new List<IMethod>();
methods.Add(CreateMethodWithoutAnyAttributes());
IMethod testMethod = CreateMethodWithAttributes("TestMethod");
methods.Add(testMethod);
AddMethodsToClass(fakeClass, methods);
List<TestMember> testMembers = GetTestMembersFor(fakeClass);
Assert.AreEqual(1, testMembers.Count);
Assert.AreEqual(testMethod, testMembers[0].Member);
}
//
// [Test]
// public void IsTestClass_ClassHasNoAttributes_ReturnsFalse()
// {
// IClass fakeClass = CreateClassWithoutAnyAttributes();
//
// bool result = testFramework.IsTestClass(fakeClass);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void IsTestClass_ClassHasTestFixtureAttributeMissingAttributePart_ReturnsTrue()
// {
// IClass fakeClass = CreateClassWithAttributes("TestClass");
//
// bool result = testFramework.IsTestClass(fakeClass);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestClass_ClassHasTestClassAttributeAndIsAbstract_ReturnsFalse()
// {
// IClass fakeClass = CreateClassWithAttributes("TestClass");
// MakeClassAbstract(fakeClass);
//
// bool result = testFramework.IsTestClass(fakeClass);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void IsTestClass_ClassHasTestClassAttributeIncludingAttributePart_ReturnsTrue()
// {
// IClass fakeClass = CreateClassWithAttributes("TestClassAttribute");
//
// bool result = testFramework.IsTestClass(fakeClass);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestClass_ClassHasFullyQualifiedMSTestClassAttribute_ReturnsTrue()
// {
// IClass fakeClass = CreateClassWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute");
//
// bool result = testFramework.IsTestClass(fakeClass);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestClass_ClassIsNull_ReturnsFalse()
// {
// bool result = testFramework.IsTestClass(null);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void IsTestMember_MethodHasNoAttributes_ReturnsFalse()
// {
// IMethod method = CreateMethodWithoutAnyAttributes();
//
// bool result = testFramework.IsTestMember(method);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void IsTestMember_MethodHasTestMethodAttributeWithoutAttributePart_ReturnsTrue()
// {
// IMethod method = CreateMethodWithAttributes("TestMethod");
//
// bool result = testFramework.IsTestMember(method);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestMember_MethodHasTestMethodAttributeAttribute_ReturnsTrue()
// {
// IMethod method = CreateMethodWithAttributes("TestMethodAttribute");
//
// bool result = testFramework.IsTestMember(method);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestMember_MethodHasFullyQualifiedMSTestTestMethodAttribute_ReturnsTrue()
// {
// IMethod method = CreateMethodWithAttributes("Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute");
//
// bool result = testFramework.IsTestMember(method);
//
// Assert.IsTrue(result);
// }
//
// [Test]
// public void IsTestMember_MethodIsNull_ReturnsFalse()
// {
// bool result = testFramework.IsTestMember(null);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void IsTestMember_MemberNotMethod_ReturnsFalse()
// {
// IMember member = MockRepository.GenerateStub<IMember>();
//
// bool result = testFramework.IsTestMember(member);
//
// Assert.IsFalse(result);
// }
//
// [Test]
// public void GetTestMembersFor_ClassHasNoMethods_ReturnsFalse()
// {
// IClass fakeClass = CreateClassWithAttributes("TestClass");
// AddMethodsToClass(fakeClass, new List<IMethod>());
//
// List<TestMember> testMembers = GetTestMembersFor(fakeClass);
//
// Assert.AreEqual(0, testMembers.Count);
// }
//
// [Test]
// public void GetTestMembersFor_ClassHasTwoMethodsAndSecondOneIsTestMethod_ReturnsSecondTestMethodOnly()
// {
// IClass fakeClass = CreateClassWithAttributes("TestClass");
//
// var methods = new List<IMethod>();
// methods.Add(CreateMethodWithoutAnyAttributes());
// IMethod testMethod = CreateMethodWithAttributes("TestMethod");
// methods.Add(testMethod);
// AddMethodsToClass(fakeClass, methods);
//
// List<TestMember> testMembers = GetTestMembersFor(fakeClass);
//
// Assert.AreEqual(1, testMembers.Count);
// Assert.AreEqual(testMethod, testMembers[0].Member);
// }
}
}

3
samples/MSTest/MSTest.SharpDevelop.Tests/MSTestResultsTests.cs

@ -7,6 +7,7 @@ using System.IO; @@ -7,6 +7,7 @@ using System.IO;
using System.Linq;
using System.Xml;
using ICSharpCode.MSTest;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.UnitTesting;
using NUnit.Framework;
@ -132,7 +133,7 @@ namespace MSTest.SharpDevelop.Tests @@ -132,7 +133,7 @@ namespace MSTest.SharpDevelop.Tests
ResultType = TestResultType.Failure,
Message = "System.ApplicationException: asdfafds",
StackTrace = " at FooTest.UnitTest1.TestMethod1() in d:\\projects\\FooTest\\UnitTest1.cs:line 21\r\n",
StackTraceFilePosition = new FilePosition(@"d:\projects\FooTest\UnitTest1.cs", 21, 1)
StackTraceFilePosition = new DomRegion(@"d:\projects\FooTest\UnitTest1.cs", 21, 1)
}
};
AssertTestResultsAreEqual(expectedResults);

2
samples/MSTest/MSTest.SharpDevelop.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.2.0.8749-Beta 2
# SharpDevelop 4.4
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTest.SharpDevelop", "MSTest.SharpDevelop\MSTest.SharpDevelop.csproj", "{8DF3A610-47F9-4448-B455-952BD57CB5CC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSTest.SharpDevelop.Tests", "MSTest.SharpDevelop.Tests\MSTest.SharpDevelop.Tests.csproj", "{51D56190-67B7-4A49-BA0A-24010460CCC6}"

16
samples/MSTest/MSTest.SharpDevelop/MSTest.SharpDevelop.csproj

@ -7,13 +7,14 @@ @@ -7,13 +7,14 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.MSTest</RootNamespace>
<AssemblyName>MSTest.SharpDevelop</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<OutputPath>..\..\..\AddIns\Samples\MSTest</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
@ -45,12 +46,12 @@ @@ -45,12 +46,12 @@
<HintPath>..\..\..\bin\ICSharpCode.Core.Presentation.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Dom">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath>
<Reference Include="ICSharpCode.SharpDevelop">
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Widgets">
@ -74,15 +75,20 @@ @@ -74,15 +75,20 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="MSTestClass.cs" />
<Compile Include="MSTestApplication.cs" />
<Compile Include="MSTestApplicationCommandLine.cs" />
<Compile Include="MSTestDebugger.cs" />
<Compile Include="MSTestFramework.cs" />
<Compile Include="MSTestMember.cs" />
<Compile Include="MSTestMonitor.cs" />
<Compile Include="MSTestOptions.cs" />
<Compile Include="MSTestOptionsPanel.xaml.cs">
<DependentUpon>MSTestOptionsPanel.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MSTestProcessRunnerContext.cs" />
<Compile Include="MSTestProject.cs" />
<Compile Include="MSTestQualifiedClassName.cs" />
<Compile Include="MSTestResult.cs" />
<Compile Include="MSTestResults.cs" />

24
samples/MSTest/MSTest.SharpDevelop/MSTestApplication.cs

@ -2,18 +2,20 @@ @@ -2,18 +2,20 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestApplication
{
SelectedTests selectedTests;
string resultsFileName;
readonly IEnumerable<ITest> selectedTests;
readonly string resultsFileName;
public MSTestApplication(SelectedTests selectedTests, string resultsFileName)
public MSTestApplication(IEnumerable<ITest> selectedTests, string resultsFileName)
{
this.selectedTests = selectedTests;
this.resultsFileName = resultsFileName;
@ -27,16 +29,18 @@ namespace ICSharpCode.MSTest @@ -27,16 +29,18 @@ namespace ICSharpCode.MSTest
string GetCommandLine()
{
ITest test = selectedTests.FirstOrDefault();
var commandLine = new MSTestApplicationCommandLine();
commandLine.AppendQuoted("testcontainer", selectedTests.Project.OutputAssemblyFullPath);
commandLine.AppendQuoted("testcontainer", test.ParentProject.Project.OutputAssemblyFullPath);
commandLine.AppendQuoted("resultsfile", resultsFileName);
commandLine.Append("detail", "errorstacktrace");
if (selectedTests.NamespaceFilter != null) {
commandLine.Append("test", selectedTests.NamespaceFilter);
} else if (selectedTests.Member != null) {
commandLine.Append("test", selectedTests.Member.FullyQualifiedName);
} else if (selectedTests.Class != null) {
commandLine.Append("test", selectedTests.Class.FullyQualifiedName);
if (test is TestNamespace) {
commandLine.Append("test", ((TestNamespace)test).NamespaceName);
} else if (test is MSTestMember) {
commandLine.Append("test", ((MSTestMember)test).Member.FullName);
} else if (test is MSTestClass) {
commandLine.Append("test", ((MSTestClass)test).GetTypeName());
}
return commandLine.ToString();
}

99
samples/MSTest/MSTest.SharpDevelop/MSTestClass.cs

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Widgets;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestClass : TestBase
{
readonly MSTestProject parentProject;
readonly FullTypeName fullTypeName;
public MSTestClass(MSTestProject parentProject, FullTypeName fullTypeName)
{
this.parentProject = parentProject;
this.fullTypeName = fullTypeName;
BindResultToCompositeResultOfNestedTests();
}
public string GetTypeName()
{
return fullTypeName.ReflectionName;
}
public override ITestProject ParentProject {
get { return parentProject; }
}
public override string DisplayName {
get { return fullTypeName.Name; }
}
protected override void OnNestedTestsInitialized()
{
ITypeDefinition typeDefinition = Resolve();
if (typeDefinition != null) {
Update(typeDefinition);
}
base.OnNestedTestsInitialized();
}
public void Update(ITypeDefinition typeDefinition)
{
if (!NestedTestsInitialized)
return;
var newOrUpdatedTests = new HashSet<ITest>();
foreach (ITest test in parentProject.GetTestMembersFor(typeDefinition)) {
MSTestMember existingTest = FindTestMember(test);
if (existingTest == null) {
NestedTestCollection.Add(test);
newOrUpdatedTests.Add(test);
} else {
newOrUpdatedTests.Add(existingTest);
}
}
NestedTestCollection.RemoveAll(t => !newOrUpdatedTests.Contains(t));
}
MSTestMember FindTestMember(ITest test)
{
var testMember = test as MSTestMember;
return FindTestMember(testMember.DisplayName);
}
public MSTestMember FindTestMember(string name)
{
return NestedTestCollection
.OfType<MSTestMember>()
.LastOrDefault(member => member.DisplayName == name);
}
public override ICommand GoToDefinition {
get {
return new RelayCommand(
delegate {
ITypeDefinition typeDefinition = Resolve();
if (typeDefinition != null)
NavigationService.NavigateTo(typeDefinition);
});
}
}
public ITypeDefinition Resolve()
{
ICompilation compilation = SD.ParserService.GetCompilation(parentProject.Project);
IType type = compilation.MainAssembly.GetTypeDefinition(fullTypeName);
return type.GetDefinition();
}
}
}

117
samples/MSTest/MSTest.SharpDevelop/MSTestDebugger.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -10,125 +11,35 @@ using ICSharpCode.UnitTesting; @@ -10,125 +11,35 @@ using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestDebugger : TestRunnerBase
public class MSTestDebugger : TestProcessRunnerBase
{
IUnitTestDebuggerService debuggerService;
IUnitTestMessageService messageService;
IDebugger debugger;
string resultsFileName;
public MSTestDebugger()
: this(
new UnitTestDebuggerService(),
new UnitTestMessageService())
public MSTestDebugger(TestExecutionOptions options)
: base(new MSTestProcessRunnerContext(options))
{
}
public MSTestDebugger(
IUnitTestDebuggerService debuggerService,
IUnitTestMessageService messageService)
{
this.debuggerService = debuggerService;
this.messageService = messageService;
this.debugger = debuggerService.CurrentDebugger;
}
public override void Start(SelectedTests selectedTests)
{
ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
if (IsDebuggerRunning) {
if (CanStopDebugging()) {
debugger.Stop();
Start(startInfo);
}
} else {
Start(startInfo);
}
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
protected override ProcessStartInfo GetProcessStartInfo(IEnumerable<ITest> selectedTests)
{
resultsFileName = new MSTestResultsFileName(selectedTests).FileName;
CreateDirectoryForResultsFile();
var mstestApplication = new MSTestApplication(selectedTests, resultsFileName);
return mstestApplication.ProcessStartInfo;
}
public bool IsDebuggerRunning {
get { return debuggerService.IsDebuggerLoaded && debugger.IsDebugging; }
}
bool CanStopDebugging()
{
string question = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}";
string caption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}";
return messageService.AskQuestion(question, caption);
}
void CreateDirectoryForResultsFile()
{
string path = Path.GetDirectoryName(resultsFileName);
if (!Directory.Exists(path)) {
Directory.CreateDirectory(path);
}
}
void Start(ProcessStartInfo startInfo)
{
StartDebugger(startInfo);
}
void StartDebugger(ProcessStartInfo startInfo)
{
LogCommandLine(startInfo);
MSTestRunner.CreateDirectoryForResultsFile(resultsFileName);
bool running = false;
debugger.DebugStopped += DebugStopped;
try {
debugger.Start(startInfo);
running = true;
} finally {
if (!running) {
debugger.DebugStopped -= DebugStopped;
}
}
}
void DebugStopped(object source, EventArgs e)
{
debugger.DebugStopped -= DebugStopped;
var monitor = (MSTestMonitor)TestResultsReader;
monitor.ResultsFileName = resultsFileName;
if (File.Exists(resultsFileName)) {
var testResults = new MSTestResults(resultsFileName);
var workbench = new UnitTestWorkbench();
workbench.SafeThreadAsyncCall(() => UpdateTestResults(testResults));
} else {
messageService.ShowFormattedErrorMessage("Unable to find test results file: '{0}'.", resultsFileName);
OnAllTestsFinished(source, e);
}
}
void UpdateTestResults(MSTestResults testResults)
{
foreach (TestResult result in testResults) {
OnTestFinished(this, new TestFinishedEventArgs(result));
}
OnAllTestsFinished(this, new EventArgs());
var app = new MSTestApplication(selectedTests, resultsFileName);
return app.ProcessStartInfo;
}
public override void Stop()
protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
{
if (debugger.IsDebugging) {
debugger.Stop();
}
return testResult;
}
public override void Dispose()
public override int GetExpectedNumberOfTestResults(IEnumerable<ITest> selectedTests)
{
Stop();
try {
File.Delete(resultsFileName);
} catch { }
return 0;
}
}
}

82
samples/MSTest/MSTest.SharpDevelop/MSTestFramework.cs

@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
@ -12,70 +10,6 @@ namespace ICSharpCode.MSTest @@ -12,70 +10,6 @@ namespace ICSharpCode.MSTest
{
public class MSTestFramework : ITestFramework
{
public bool IsBuildNeededBeforeTestRun {
get { return true; }
}
public bool IsTestMember(IMember member)
{
var method = member as IMethod;
if (method == null)
return false;
return IsTestMethod(method);
}
bool IsTestMethod(IMethod method)
{
foreach (IAttribute attribute in method.Attributes) {
if (IsMSTestMethodAttribute(attribute)) {
return true;
}
}
return false;
}
bool IsMSTestMethodAttribute(IAttribute attribute)
{
return IsMSTestMethodAttribute(attribute.AttributeType.FullyQualifiedName);
}
bool IsMSTestMethodAttribute(string name)
{
return
name == "TestMethod" ||
name == "TestMethodAttribute" ||
name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";
}
public bool IsTestClass(IClass c)
{
if ((c == null) || (c.IsAbstract))
return false;
foreach (IAttribute attribute in c.Attributes) {
if (IsMSTestClassAttribute(attribute)) {
return true;
}
}
return false;
}
bool IsMSTestClassAttribute(IAttribute attribute)
{
return IsMSTestClassAttribute(attribute.AttributeType.FullyQualifiedName);
}
bool IsMSTestClassAttribute(string name)
{
return
name == "TestClass" ||
name == "TestClassAttribute" ||
name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
}
public bool IsTestProject(IProject project)
{
if (project == null)
@ -89,21 +23,9 @@ namespace ICSharpCode.MSTest @@ -89,21 +23,9 @@ namespace ICSharpCode.MSTest
return false;
}
public IEnumerable<TestMember> GetTestMembersFor(IClass c)
{
return c.Methods
.Where(IsTestMethod)
.Select(method => new TestMember(method));
}
public ITestRunner CreateTestRunner()
{
return new MSTestRunner();
}
public ITestRunner CreateTestDebugger()
public ITestProject CreateTestProject(ITestSolution parentSolution, IProject project)
{
return new MSTestDebugger();
return new MSTestProject(project);
}
}
}

72
samples/MSTest/MSTest.SharpDevelop/MSTestMember.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Windows.Input;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Widgets;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestMember : TestBase
{
readonly MSTestProject parentProject;
readonly string displayName;
readonly IMember member;
MSTestMember(MSTestProject parentProject, string displayName)
{
this.parentProject = parentProject;
this.displayName = displayName;
}
public MSTestMember(
MSTestProject parentProject,
IMember member)
: this(parentProject, member.Name)
{
this.member = member;
}
public override ITestProject ParentProject {
get { return parentProject; }
}
public override string DisplayName {
get { return displayName; }
}
public void UpdateTestResult(TestResult result)
{
this.Result = result.ResultType;
}
public IMember Member {
get { return this.member; }
}
public IMember Resolve()
{
ICompilation compilation = SD.ParserService.GetCompilation(parentProject.Project);
return member.UnresolvedMember.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly));
}
public override ICommand GoToDefinition {
get {
return new RelayCommand(
delegate {
IMember member = Resolve();
if (member != null)
NavigationService.NavigateTo(member);
});
}
}
public virtual string GetTypeName()
{
return member.DeclaringTypeDefinition.FullName;
}
}
}

60
samples/MSTest/MSTest.SharpDevelop/MSTestMonitor.cs

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestMonitor : ITestResultsReader
{
public event EventHandler<TestFinishedEventArgs> TestFinished;
public string ResultsFileName { get; set; }
public void Join()
{
if (File.Exists(ResultsFileName)) {
var testResults = new MSTestResults(ResultsFileName);
UpdateTestResults(testResults);
}
}
void UpdateTestResults(MSTestResults testResults)
{
foreach (TestResult result in testResults) {
OnTestFinished(new TestFinishedEventArgs(result));
}
}
void OnTestFinished(TestFinishedEventArgs e)
{
if (TestFinished != null) {
TestFinished(this, e);
}
}
public void Start()
{
TryDeleteResultsFile();
}
public string PipeName {
get { return String.Empty; }
}
public void Dispose()
{
}
void TryDeleteResultsFile()
{
try {
Console.WriteLine("Deleting results file: " + ResultsFileName);
File.Delete(ResultsFileName);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}
}
}

2
samples/MSTest/MSTest.SharpDevelop/MSTestOptions.cs

@ -9,7 +9,7 @@ namespace ICSharpCode.MSTest @@ -9,7 +9,7 @@ namespace ICSharpCode.MSTest
{
public static class MSTestOptions
{
static Properties properties = PropertyService.Get("MSTestOptions", new Properties());
static readonly Properties properties = PropertyService.NestedProperties("MSTestOptions");
public static string MSTestPath {
get { return properties.Get<string>("MSTestPath", GetDefaultMSTestPath()); }

13
samples/MSTest/MSTest.SharpDevelop/MSTestOptionsPanel.xaml.cs

@ -12,7 +12,7 @@ using Microsoft.Win32; @@ -12,7 +12,7 @@ using Microsoft.Win32;
namespace ICSharpCode.MSTest
{
public partial class MSTestOptionsPanel : OptionPanel, INotifyPropertyChanged
public partial class MSTestOptionsPanel : OptionPanel
{
string msTestPath;
bool changed;
@ -40,7 +40,7 @@ namespace ICSharpCode.MSTest @@ -40,7 +40,7 @@ namespace ICSharpCode.MSTest
set {
msTestPath = value;
changed = true;
OnPropertyChanged("MSTestPath");
RaisePropertyChanged("MSTestPath");
}
}
@ -51,14 +51,5 @@ namespace ICSharpCode.MSTest @@ -51,14 +51,5 @@ namespace ICSharpCode.MSTest
}
return true;
}
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
}
}

22
samples/MSTest/MSTest.SharpDevelop/MSTestProcessRunnerContext.cs

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestProcessRunnerContext : TestProcessRunnerBaseContext
{
public MSTestProcessRunnerContext(TestExecutionOptions options)
: base(
options,
new ProcessRunner(),
new MSTestMonitor(),
SD.FileSystem,
SD.MessageService)
{
}
}
}

129
samples/MSTest/MSTest.SharpDevelop/MSTestProject.cs

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestProject : TestProjectBase
{
public MSTestProject(IProject project)
: base(project)
{
}
public override ITestRunner CreateTestRunner(TestExecutionOptions options)
{
if (options.UseDebugger) {
return new MSTestDebugger(options);
}
return new MSTestRunner(options);
}
protected override bool IsTestClass(ITypeDefinition typeDefinition)
{
if ((typeDefinition == null) || (typeDefinition.IsAbstract)) {
return false;
}
foreach (IAttribute attribute in typeDefinition.Attributes) {
if (IsMSTestClassAttribute(attribute)) {
return true;
}
}
return false;
}
bool IsMSTestClassAttribute(IAttribute attribute)
{
return IsMSTestClassAttribute(attribute.AttributeType.FullName);
}
bool IsMSTestClassAttribute(string name)
{
return
name == "TestClass" ||
name == "TestClassAttribute" ||
name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
}
protected override ITest CreateTestClass(ITypeDefinition typeDefinition)
{
if (IsTestClass(typeDefinition)) {
return new MSTestClass(this, typeDefinition.FullTypeName);
}
return null;
}
protected override void UpdateTestClass(ITest test, ITypeDefinition typeDefinition)
{
var testClass = test as MSTestClass;
testClass.Update(typeDefinition);
}
public override IEnumerable<ITest> GetTestsForEntity(IEntity entity)
{
return new ITest[0];
}
public override void UpdateTestResult(TestResult result)
{
// Code duplication - taken from NUnitTestProject
int lastDot = result.Name.LastIndexOf('.');
if (lastDot < 0) {
return;
}
string fixtureName = result.Name.Substring(0, lastDot);
string memberName = result.Name.Substring(lastDot + 1);
MSTestClass testClass = GetMSTestClass(new FullTypeName(fixtureName));
MSTestMember test = testClass.FindTestMember(memberName);
if (test != null) {
test.UpdateTestResult(result);
}
}
MSTestClass GetMSTestClass(FullTypeName fullTypeName)
{
return GetTestClass(fullTypeName.TopLevelTypeName) as MSTestClass;
}
bool IsTestMethod(IMethod method)
{
foreach (IAttribute attribute in method.Attributes) {
if (IsMSTestMethodAttribute(attribute)) {
return true;
}
}
return false;
}
bool IsMSTestMethodAttribute(IAttribute attribute)
{
return IsMSTestMethodAttribute(attribute.AttributeType.FullName);
}
bool IsMSTestMethodAttribute(string name)
{
return
name == "TestMethod" ||
name == "TestMethodAttribute" ||
name == "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";
}
public IEnumerable<MSTestMember> GetTestMembersFor(ITypeDefinition typeDefinition)
{
return typeDefinition.Methods
.Where(IsTestMethod)
.Select(method => new MSTestMember(this, method));
}
}
}

13
samples/MSTest/MSTest.SharpDevelop/MSTestResult.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.IO;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.UnitTesting;
@ -67,27 +68,27 @@ namespace ICSharpCode.MSTest @@ -67,27 +68,27 @@ namespace ICSharpCode.MSTest
return Message;
}
FilePosition GetStackTraceFilePosition()
DomRegion GetStackTraceFilePosition()
{
if (!String.IsNullOrEmpty(StackTrace)) {
return ParseFilePositionFromStackTrace();
}
return FilePosition.Empty;
return DomRegion.Empty;
}
FilePosition ParseFilePositionFromStackTrace()
DomRegion ParseFilePositionFromStackTrace()
{
FileLineReference fileLineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(StackTrace, true);
if (fileLineRef != null) {
return CreateFilePosition(fileLineRef);
}
return FilePosition.Empty;
return DomRegion.Empty;
}
FilePosition CreateFilePosition(FileLineReference fileLineRef)
DomRegion CreateFilePosition(FileLineReference fileLineRef)
{
string fileName = Path.GetFullPath(fileLineRef.FileName);
return new FilePosition(fileName, fileLineRef.Line, fileLineRef.Column + 1);
return new DomRegion(fileName, fileLineRef.Line, fileLineRef.Column + 1);
}
}
}

9
samples/MSTest/MSTest.SharpDevelop/MSTestResultsFileName.cs

@ -2,26 +2,29 @@ @@ -2,26 +2,29 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestResultsFileName
{
public MSTestResultsFileName(SelectedTests selectedTests)
public MSTestResultsFileName(IEnumerable<ITest> selectedTests)
{
FileName = GetFileName(selectedTests);
}
public string FileName { get; private set; }
string GetFileName(SelectedTests selectedTests)
string GetFileName(IEnumerable<ITest> selectedTests)
{
return Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Temp",
selectedTests.Project.Name + "-Results.trx");
selectedTests.First().ParentProject.Project.Name + "-Results.trx");
}
}
}

118
samples/MSTest/MSTest.SharpDevelop/MSTestRunner.cs

@ -2,97 +2,36 @@ @@ -2,97 +2,36 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using ICSharpCode.SharpDevelop.Util;
using ICSharpCode.UnitTesting;
namespace ICSharpCode.MSTest
{
public class MSTestRunner : TestRunnerBase
public class MSTestRunner : TestProcessRunnerBase
{
IUnitTestProcessRunner processRunner;
IFileSystem fileSystem;
IUnitTestMessageService messageService;
string resultsFileName;
public MSTestRunner()
: this(new UnitTestProcessRunner(),
new UnitTestFileService(),
new UnitTestMessageService())
public MSTestRunner(TestExecutionOptions options)
: base(new MSTestProcessRunnerContext(options))
{
}
public MSTestRunner(
IUnitTestProcessRunner processRunner,
IFileSystem fileSystem,
IUnitTestMessageService messageService)
{
this.processRunner = processRunner;
this.fileSystem = fileSystem;
this.messageService = messageService;
processRunner.LogStandardOutputAndError = false;
processRunner.OutputLineReceived += OutputLineReceived;
processRunner.ErrorLineReceived += OutputLineReceived;
processRunner.ProcessExited += ProcessRunnerExited;
}
void ProcessRunnerExited(object source, EventArgs e)
{
// Read all tests.
if (FileExists(resultsFileName)) {
var testResults = new MSTestResults(resultsFileName);
var workbench = new UnitTestWorkbench();
workbench.SafeThreadAsyncCall(() => UpdateTestResults(testResults));
} else {
messageService.ShowFormattedErrorMessage("Unable to find test results file: '{0}'.", resultsFileName);
OnAllTestsFinished(source, e);
}
}
void UpdateTestResults(MSTestResults testResults)
{
foreach (TestResult result in testResults) {
OnTestFinished(this, new TestFinishedEventArgs(result));
}
OnAllTestsFinished(this, new EventArgs());
}
void OutputLineReceived(object source, LineReceivedEventArgs e)
{
OnMessageReceived(e.Line);
}
public override void Start(SelectedTests selectedTests)
{
ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests);
TryDeleteResultsFile();
Start(startInfo);
}
protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests)
protected override ProcessStartInfo GetProcessStartInfo(IEnumerable<ITest> selectedTests)
{
resultsFileName = new MSTestResultsFileName(selectedTests).FileName;
CreateDirectoryForResultsFile();
var mstestApplication = new MSTestApplication(selectedTests, resultsFileName);
return mstestApplication.ProcessStartInfo;
}
void Start(ProcessStartInfo processStartInfo)
{
LogCommandLine(processStartInfo);
CreateDirectoryForResultsFile(resultsFileName);
if (FileExists(processStartInfo.FileName)) {
processRunner.WorkingDirectory = processStartInfo.WorkingDirectory;
processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments);
} else {
ShowApplicationDoesNotExistMessage(processStartInfo.FileName);
}
var monitor = (MSTestMonitor)TestResultsReader;
monitor.ResultsFileName = resultsFileName;
var app = new MSTestApplication(selectedTests, resultsFileName);
return app.ProcessStartInfo;
}
void CreateDirectoryForResultsFile()
public static void CreateDirectoryForResultsFile(string resultsFileName)
{
string path = Path.GetDirectoryName(resultsFileName);
if (!Directory.Exists(path)) {
@ -100,39 +39,14 @@ namespace ICSharpCode.MSTest @@ -100,39 +39,14 @@ namespace ICSharpCode.MSTest
}
}
bool FileExists(string fileName)
{
return fileSystem.FileExists(fileName);
}
void ShowApplicationDoesNotExistMessage(string fileName)
protected override TestResult CreateTestResultForTestFramework(TestResult testResult)
{
string resourceString = "${res:ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat}";
messageService.ShowFormattedErrorMessage(resourceString, fileName);
return testResult;
}
public override void Stop()
public override int GetExpectedNumberOfTestResults(IEnumerable<ITest> selectedTests)
{
processRunner.Kill();
}
public override void Dispose()
{
processRunner.ErrorLineReceived -= OutputLineReceived;
processRunner.OutputLineReceived -= OutputLineReceived;
processRunner.ProcessExited -= ProcessRunnerExited;
TryDeleteResultsFile();
}
void TryDeleteResultsFile()
{
try {
Console.WriteLine("Deleting results file: " + resultsFileName);
File.Delete(resultsFileName);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
return 0;
}
}
}

Loading…
Cancel
Save