139 changed files with 17774 additions and 456 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{51D56190-67B7-4A49-BA0A-24010460CCC6}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>MSTest.SharpDevelop.Tests</RootNamespace> |
||||
<AssemblyName>MSTest.SharpDevelop.Tests</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>bin\Debug\</OutputPath> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>bin\Release\</OutputPath> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="ICSharpCode.Core"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.Core.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> |
||||
<Reference Include="Rhino.Mocks"> |
||||
<HintPath>..\..\..\src\Libraries\RhinoMocks\Rhino.Mocks.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="UnitTesting"> |
||||
<HintPath>..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll</HintPath> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="MSTestFrameworkTests.cs" /> |
||||
<Compile Include="MSTestResultsTests.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\MSTest.SharpDevelop\MSTest.SharpDevelop.csproj"> |
||||
<Project>{8DF3A610-47F9-4448-B455-952BD57CB5CC}</Project> |
||||
<Name>MSTest.SharpDevelop</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,338 @@
@@ -0,0 +1,338 @@
|
||||
// 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.Collections.ObjectModel; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.MSTest; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
using Rhino.Mocks; |
||||
|
||||
namespace MSTest.SharpDevelop.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MSTestFrameworkTests |
||||
{ |
||||
MSTestFramework testFramework; |
||||
IProject fakeProject; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
testFramework = new MSTestFramework(); |
||||
|
||||
fakeProject = MockRepository.GenerateStub<IProject>(); |
||||
fakeProject.Stub(p => p.SyncRoot).Return(fakeProject); |
||||
} |
||||
|
||||
void AddReferencesToProject(params string[] referenceNames) |
||||
{ |
||||
List<ProjectItem> projectItems = referenceNames |
||||
.Select(name => new ReferenceProjectItem(fakeProject, name) as ProjectItem) |
||||
.ToList(); |
||||
|
||||
AddItemsToProject(projectItems); |
||||
} |
||||
|
||||
void AddItemsToProject(List<ProjectItem> projectItems) |
||||
{ |
||||
fakeProject |
||||
.Stub(project => project.Items) |
||||
.Return(new ReadOnlyCollection<ProjectItem>(projectItems)); |
||||
} |
||||
|
||||
void AddFileAndReferenceToProject(string fileName, string reference) |
||||
{ |
||||
var projectItems = new List<ProjectItem>(); |
||||
projectItems.Add(new FileProjectItem(fakeProject, ItemType.Compile, fileName)); |
||||
projectItems.Add(new ReferenceProjectItem(fakeProject, reference)); |
||||
|
||||
AddItemsToProject(projectItems); |
||||
} |
||||
|
||||
void NoItemsInProject() |
||||
{ |
||||
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); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_NullProject_ReturnsFalse() |
||||
{ |
||||
bool result = testFramework.IsTestProject(null); |
||||
|
||||
Assert.IsFalse(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_ProjectWithMSTestAssemblyReference_ReturnsTrue() |
||||
{ |
||||
AddReferencesToProject("System", "Microsoft.VisualStudio.QualityTools.UnitTestFramework"); |
||||
|
||||
bool result = testFramework.IsTestProject(fakeProject); |
||||
|
||||
Assert.IsTrue(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_ProjectWithoutMSTestAssemblyReference_ReturnsFalse() |
||||
{ |
||||
NoItemsInProject(); |
||||
bool result = testFramework.IsTestProject(fakeProject); |
||||
|
||||
Assert.IsFalse(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_ProjectWithMSTestAssemblyReferenceInUpperCase_ReturnsTrue() |
||||
{ |
||||
AddReferencesToProject("MICROSOFT.VISUALSTUDIO.QUALITYTOOLS.UNITTESTFRAMEWORK"); |
||||
|
||||
bool result = testFramework.IsTestProject(fakeProject); |
||||
|
||||
Assert.IsTrue(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_ProjectWithMSTestAssemblyReferenceAndFileProjectItem_ReturnsTrue() |
||||
{ |
||||
AddFileAndReferenceToProject("test.cs", "Microsoft.VisualStudio.QualityTools.UnitTestFramework"); |
||||
|
||||
bool result = testFramework.IsTestProject(fakeProject); |
||||
|
||||
Assert.IsTrue(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTestProject_ProjectWithMSTestAssemblyReferenceUsingFullName_ReturnsTrue() |
||||
{ |
||||
AddReferencesToProject("Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"); |
||||
|
||||
bool result = testFramework.IsTestProject(fakeProject); |
||||
|
||||
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); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
// 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.IO; |
||||
using System.Linq; |
||||
using System.Xml; |
||||
using ICSharpCode.MSTest; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.UnitTesting; |
||||
using NUnit.Framework; |
||||
|
||||
namespace MSTest.SharpDevelop.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class MSTestResultsTests |
||||
{ |
||||
MSTestResults testResults; |
||||
|
||||
void CreateMSTestResults(string xml) |
||||
{ |
||||
using (var reader = new XmlTextReader(new StringReader(xml))) { |
||||
testResults = new MSTestResults(reader); |
||||
} |
||||
} |
||||
|
||||
void AssertTestResultsAreEqual(TestResult[] expectedResults) |
||||
{ |
||||
List<string> expectedResultsAsString = ConvertToStrings(expectedResults); |
||||
List<string> actualResultsAsString = ConvertToStrings(testResults); |
||||
CollectionAssert.AreEqual(expectedResultsAsString, actualResultsAsString); |
||||
} |
||||
|
||||
List<string> ConvertToStrings(IEnumerable<TestResult> results) |
||||
{ |
||||
return results.Select( |
||||
result => String.Format( |
||||
"Name: {0}, Result: {1}, Message: '{2}', StackTrace: '{3}', StackPosition: {4}", |
||||
result.Name, |
||||
result.ResultType, |
||||
result.Message, |
||||
result.StackTrace, |
||||
result.StackTraceFilePosition)) |
||||
.ToList(); |
||||
} |
||||
|
||||
[Test] |
||||
public void Results_OneClassWithTwoPassingTestMethods_ReturnsTwoResults() |
||||
{ |
||||
CreateMSTestResults(oneClassWithTwoPassingTestMethods); |
||||
|
||||
var expectedResults = new TestResult[] { |
||||
new TestResult("FooTest.UnitTest1.TestMethod1") { |
||||
ResultType = TestResultType.Success |
||||
}, |
||||
new TestResult("FooTest.UnitTest1.TestMethod2") { |
||||
ResultType = TestResultType.Success |
||||
}, |
||||
}; |
||||
AssertTestResultsAreEqual(expectedResults); |
||||
} |
||||
|
||||
string oneClassWithTwoPassingTestMethods = |
||||
|
||||
@"<?xml version=""1.0"" encoding=""UTF-8""?>
|
||||
<TestRun id=""13473da1-70ea-422c-86a5-3b5d04610561"" name=""FEYNMAN 2012-05-06 11:02:13"" runUser=""Feynman\Matt"" xmlns=""http://microsoft.com/schemas/VisualStudio/TeamTest/2010"">
|
||||
<TestSettings name=""Local"" id=""1af0c4fe-35c7-49e5-b22a-40677255db56""> |
||||
<Description>These are default test settings for a local test run.</Description> |
||||
<Deployment runDeploymentRoot=""FEYNMAN 2012-05-06 11_02_13""> |
||||
<DeploymentItem filename=""T4Scaffolding.Test\ExampleScripts\"" /> |
||||
</Deployment> |
||||
<Execution> |
||||
<TestTypeSpecific> |
||||
<UnitTestRunConfig testTypeId=""13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b""> |
||||
<AssemblyResolution> |
||||
<TestDirectory useLoadContext=""true"" /> |
||||
</AssemblyResolution> |
||||
</UnitTestRunConfig> |
||||
<WebTestRunConfiguration testTypeId=""4e7599fa-5ecb-43e9-a887-cd63cf72d207""> |
||||
<Browser name=""Internet Explorer 7.0""> |
||||
<Headers> |
||||
<Header name=""User-Agent"" value=""Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"" /> |
||||
<Header name=""Accept"" value=""*/*"" /> |
||||
<Header name=""Accept-Language"" value=""{{$IEAcceptLanguage}}"" /> |
||||
<Header name=""Accept-Encoding"" value=""GZIP"" /> |
||||
</Headers> |
||||
</Browser> |
||||
</WebTestRunConfiguration> |
||||
</TestTypeSpecific> |
||||
<AgentRule name=""LocalMachineDefaultRole""> |
||||
</AgentRule> |
||||
</Execution> |
||||
</TestSettings> |
||||
<Times creation=""2012-05-06T11:02:13.0655060+01:00"" queuing=""2012-05-06T11:02:16.0845060+01:00"" start=""2012-05-06T11:02:16.4355060+01:00"" finish=""2012-05-06T11:02:17.8915060+01:00"" /> |
||||
<ResultSummary outcome=""Completed""> |
||||
<Counters total=""2"" executed=""2"" passed=""2"" error=""0"" failed=""0"" timeout=""0"" aborted=""0"" inconclusive=""0"" passedButRunAborted=""0"" notRunnable=""0"" notExecuted=""0"" disconnected=""0"" warning=""0"" completed=""0"" inProgress=""0"" pending=""0"" /> |
||||
</ResultSummary> |
||||
<TestDefinitions> |
||||
<UnitTest name=""TestMethod2"" storage=""d:\temp\test\mvcscaffolding_31fa7ea49b52\footest\bin\debug\footest.dll"" id=""760d70dc-fcd4-bd05-26dd-50b565053466""> |
||||
<Execution id=""4d09aff0-ba01-4c01-9c3c-dd6475e89ef2"" /> |
||||
<TestMethod codeBase=""D:/projects/FooTest/bin/Debug/FooTest.DLL"" adapterTypeName=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" className=""FooTest.UnitTest1, FooTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"" name=""TestMethod2"" /> |
||||
</UnitTest> |
||||
<UnitTest name=""TestMethod1"" storage=""d:\temp\test\mvcscaffolding_31fa7ea49b52\footest\bin\debug\footest.dll"" id=""752967dd-f45f-65ac-ca4a-dcd30f56a25a""> |
||||
<Execution id=""ba931d00-d381-43c3-b0f9-f4cf37015438"" /> |
||||
<TestMethod codeBase=""D:/projects/FooTest/bin/Debug/FooTest.DLL"" adapterTypeName=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" className=""FooTest.UnitTest1, FooTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"" name=""TestMethod1"" /> |
||||
</UnitTest> |
||||
</TestDefinitions> |
||||
<TestLists> |
||||
<TestList name=""Results Not in a List"" id=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" /> |
||||
<TestList name=""All Loaded Results"" id=""19431567-8539-422a-85d7-44ee4e166bda"" /> |
||||
</TestLists> |
||||
<TestEntries> |
||||
<TestEntry testId=""752967dd-f45f-65ac-ca4a-dcd30f56a25a"" executionId=""ba931d00-d381-43c3-b0f9-f4cf37015438"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" /> |
||||
<TestEntry testId=""760d70dc-fcd4-bd05-26dd-50b565053466"" executionId=""4d09aff0-ba01-4c01-9c3c-dd6475e89ef2"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" /> |
||||
</TestEntries> |
||||
<Results> |
||||
<UnitTestResult executionId=""ba931d00-d381-43c3-b0f9-f4cf37015438"" testId=""752967dd-f45f-65ac-ca4a-dcd30f56a25a"" testName=""TestMethod1"" computerName=""FEYNMAN"" duration=""00:00:00.0501283"" startTime=""2012-05-06T11:02:16.5755060+01:00"" endTime=""2012-05-06T11:02:17.7465060+01:00"" testType=""13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b"" outcome=""Passed"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" relativeResultsDirectory=""ba931d00-d381-43c3-b0f9-f4cf37015438""> |
||||
</UnitTestResult> |
||||
<UnitTestResult executionId=""4d09aff0-ba01-4c01-9c3c-dd6475e89ef2"" testId=""760d70dc-fcd4-bd05-26dd-50b565053466"" testName=""TestMethod2"" computerName=""FEYNMAN"" duration=""00:00:00.0018331"" startTime=""2012-05-06T11:02:17.7655060+01:00"" endTime=""2012-05-06T11:02:17.7785060+01:00"" testType=""13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b"" outcome=""Passed"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" relativeResultsDirectory=""4d09aff0-ba01-4c01-9c3c-dd6475e89ef2""> |
||||
</UnitTestResult> |
||||
</Results> |
||||
</TestRun>";
|
||||
|
||||
[Test] |
||||
public void Results_OneTestMethodThrowsException_ReturnsOneErrorResultWithStackTrace() |
||||
{ |
||||
CreateMSTestResults(oneTestMethodThrowsException); |
||||
|
||||
var expectedResults = new TestResult[] { |
||||
new TestResult("FooTest.UnitTest1.TestMethod1") { |
||||
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) |
||||
} |
||||
}; |
||||
AssertTestResultsAreEqual(expectedResults); |
||||
} |
||||
|
||||
string oneTestMethodThrowsException = |
||||
|
||||
@"<?xml version=""1.0"" encoding=""UTF-8""?>
|
||||
<TestRun id=""7c0b0a20-13c6-4c28-b74c-e29c271f2ec4"" name=""FEYNMAN 2012-05-06 13:07:05"" runUser=""Feynman\Matt"" xmlns=""http://microsoft.com/schemas/VisualStudio/TeamTest/2010"">
|
||||
<TestSettings name=""Default Test Settings"" id=""03cf0958-a7e3-4b25-b98b-435f01359ee1""> |
||||
<Execution> |
||||
<TestTypeSpecific /> |
||||
<AgentRule name=""Execution Agents""> |
||||
</AgentRule> |
||||
</Execution> |
||||
<Deployment runDeploymentRoot=""FEYNMAN 2012-05-06 13_07_05"" /> |
||||
</TestSettings> |
||||
<Times creation=""2012-05-06T13:07:05.9187060+01:00"" queuing=""2012-05-06T13:07:06.6519060+01:00"" start=""2012-05-06T13:07:06.8235060+01:00"" finish=""2012-05-06T13:07:08.0403060+01:00"" /> |
||||
<ResultSummary outcome=""Failed""> |
||||
<Counters total=""1"" executed=""1"" passed=""0"" error=""0"" failed=""1"" timeout=""0"" aborted=""0"" inconclusive=""0"" passedButRunAborted=""0"" notRunnable=""0"" notExecuted=""0"" disconnected=""0"" warning=""0"" completed=""0"" inProgress=""0"" pending=""0"" /> |
||||
</ResultSummary> |
||||
<TestDefinitions> |
||||
<UnitTest name=""TestMethod1"" storage=""d:\projects\footest\bin\debug\footest.dll"" id=""752967dd-f45f-65ac-ca4a-dcd30f56a25a""> |
||||
<Execution id=""c147e8ae-7ee7-4f28-9db3-a708e350c68d"" /> |
||||
<TestMethod codeBase=""D:/projects/FooTest/bin/Debug/FooTest.DLL"" adapterTypeName=""Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapter, Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" className=""FooTest.UnitTest1, FooTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"" name=""TestMethod1"" /> |
||||
</UnitTest> |
||||
</TestDefinitions> |
||||
<TestLists> |
||||
<TestList name=""Results Not in a List"" id=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" /> |
||||
<TestList name=""All Loaded Results"" id=""19431567-8539-422a-85d7-44ee4e166bda"" /> |
||||
</TestLists> |
||||
<TestEntries> |
||||
<TestEntry testId=""752967dd-f45f-65ac-ca4a-dcd30f56a25a"" executionId=""c147e8ae-7ee7-4f28-9db3-a708e350c68d"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" /> |
||||
</TestEntries> |
||||
<Results> |
||||
<UnitTestResult executionId=""c147e8ae-7ee7-4f28-9db3-a708e350c68d"" testId=""752967dd-f45f-65ac-ca4a-dcd30f56a25a"" testName=""TestMethod1"" computerName=""FEYNMAN"" duration=""00:00:00.0404760"" startTime=""2012-05-06T13:07:06.9015060+01:00"" endTime=""2012-05-06T13:07:07.8375060+01:00"" testType=""13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b"" outcome=""Failed"" testListId=""8c84fa94-04c1-424b-9868-57a2d4851a1d"" relativeResultsDirectory=""c147e8ae-7ee7-4f28-9db3-a708e350c68d""> |
||||
<Output> |
||||
<ErrorInfo> |
||||
<Message>Test method FooTest.UnitTest1.TestMethod1 threw exception: |
||||
System.ApplicationException: asdfafds</Message> |
||||
<StackTrace> at FooTest.UnitTest1.TestMethod1() in d:\projects\FooTest\UnitTest1.cs:line 21 |
||||
</StackTrace> |
||||
</ErrorInfo> |
||||
</Output> |
||||
</UnitTestResult> |
||||
</Results> |
||||
</TestRun>";
|
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MSTest.SharpDevelop.Tests")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("MSTest.SharpDevelop.Tests")] |
||||
[assembly: AssemblyCopyright("Copyright 2012")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0")] |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00 |
||||
# Visual Studio 2010 |
||||
# SharpDevelop 4.2.0.8749-Beta 2 |
||||
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}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|x86 = Debug|x86 |
||||
Release|x86 = Release|x86 |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{8DF3A610-47F9-4448-B455-952BD57CB5CC}.Debug|x86.Build.0 = Debug|x86 |
||||
{8DF3A610-47F9-4448-B455-952BD57CB5CC}.Debug|x86.ActiveCfg = Debug|x86 |
||||
{8DF3A610-47F9-4448-B455-952BD57CB5CC}.Release|x86.Build.0 = Release|x86 |
||||
{8DF3A610-47F9-4448-B455-952BD57CB5CC}.Release|x86.ActiveCfg = Release|x86 |
||||
{51D56190-67B7-4A49-BA0A-24010460CCC6}.Debug|x86.Build.0 = Debug|x86 |
||||
{51D56190-67B7-4A49-BA0A-24010460CCC6}.Debug|x86.ActiveCfg = Debug|x86 |
||||
{51D56190-67B7-4A49-BA0A-24010460CCC6}.Release|x86.Build.0 = Release|x86 |
||||
{51D56190-67B7-4A49-BA0A-24010460CCC6}.Release|x86.ActiveCfg = Release|x86 |
||||
EndGlobalSection |
||||
EndGlobal |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{8DF3A610-47F9-4448-B455-952BD57CB5CC}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.MSTest</RootNamespace> |
||||
<AssemblyName>MSTest.SharpDevelop</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<OutputPath>..\..\..\AddIns\Samples\MSTest</OutputPath> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="ICSharpCode.Core"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.Core.Presentation"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.Core.Presentation.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.SharpDevelop"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.SharpDevelop.Dom"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="ICSharpCode.SharpDevelop.Widgets"> |
||||
<HintPath>..\..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xaml"> |
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="UnitTesting"> |
||||
<HintPath>..\..\..\AddIns\Analysis\UnitTesting\UnitTesting.dll</HintPath> |
||||
<Private>False</Private> |
||||
</Reference> |
||||
<Reference Include="WindowsBase" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="MSTestApplication.cs" /> |
||||
<Compile Include="MSTestApplicationCommandLine.cs" /> |
||||
<Compile Include="MSTestDebugger.cs" /> |
||||
<Compile Include="MSTestFramework.cs" /> |
||||
<Compile Include="MSTestOptions.cs" /> |
||||
<Compile Include="MSTestOptionsPanel.xaml.cs"> |
||||
<DependentUpon>MSTestOptionsPanel.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="MSTestQualifiedClassName.cs" /> |
||||
<Compile Include="MSTestResult.cs" /> |
||||
<Compile Include="MSTestResults.cs" /> |
||||
<Compile Include="MSTestResultsFileName.cs" /> |
||||
<Compile Include="MSTestRunner.cs" /> |
||||
<Compile Include="ProjectItemExtensions.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="MSTest.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="MSTestOptionsPanel.xaml" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
<AddIn |
||||
name="MSTest" |
||||
author="Matt Ward" |
||||
copyright="prj:///doc/copyright.txt" |
||||
description="MSTest support"> |
||||
|
||||
<Manifest> |
||||
<Identity name="ICSharpCode.MSTest"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly=":ICSharpCode.SharpDevelop"/> |
||||
<Import assembly="$ICSharpCode.UnitTesting/UnitTesting.dll"/> |
||||
<Import assembly="MSTest.SharpDevelop.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name="/SharpDevelop/UnitTesting/TestFrameworks"> |
||||
<TestFramework |
||||
id="mstest" |
||||
class="ICSharpCode.MSTest.MSTestFramework" |
||||
supportedProjects=".csproj"/> |
||||
</Path> |
||||
|
||||
<Path name="/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions"> |
||||
<OptionPanel |
||||
id="MSTestOptionsPanel" |
||||
label="MS Test" |
||||
class="ICSharpCode.MSTest.MSTestOptionsPanel"/> |
||||
</Path> |
||||
</AddIn> |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
// 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.Diagnostics; |
||||
|
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestApplication |
||||
{ |
||||
SelectedTests selectedTests; |
||||
string resultsFileName; |
||||
|
||||
public MSTestApplication(SelectedTests selectedTests, string resultsFileName) |
||||
{ |
||||
this.selectedTests = selectedTests; |
||||
this.resultsFileName = resultsFileName; |
||||
GetProcessStartInfo(); |
||||
} |
||||
|
||||
void GetProcessStartInfo() |
||||
{ |
||||
ProcessStartInfo = new ProcessStartInfo(MSTestOptions.MSTestPath, GetCommandLine()); |
||||
} |
||||
|
||||
string GetCommandLine() |
||||
{ |
||||
var commandLine = new MSTestApplicationCommandLine(); |
||||
commandLine.AppendQuoted("testcontainer", selectedTests.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); |
||||
} |
||||
return commandLine.ToString(); |
||||
} |
||||
|
||||
public ProcessStartInfo ProcessStartInfo { get; private set; } |
||||
} |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// 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.Text; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestApplicationCommandLine |
||||
{ |
||||
StringBuilder commandLine = new StringBuilder(); |
||||
|
||||
public MSTestApplicationCommandLine() |
||||
{ |
||||
} |
||||
|
||||
public void Append(string argument, string value) |
||||
{ |
||||
AppendFormat("/{0}:{1} ", argument, value); |
||||
} |
||||
|
||||
public void AppendQuoted(string argument, string value) |
||||
{ |
||||
AppendFormat("/{0}:\"{1}\" ", argument, value); |
||||
} |
||||
|
||||
void AppendFormat(string format, string argument, string value) |
||||
{ |
||||
commandLine.AppendFormat(format, argument, value); |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return commandLine.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,134 @@
@@ -0,0 +1,134 @@
|
||||
// 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.Diagnostics; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestDebugger : TestRunnerBase |
||||
{ |
||||
IUnitTestDebuggerService debuggerService; |
||||
IUnitTestMessageService messageService; |
||||
IDebugger debugger; |
||||
string resultsFileName; |
||||
|
||||
public MSTestDebugger() |
||||
: this( |
||||
new UnitTestDebuggerService(), |
||||
new UnitTestMessageService()) |
||||
{ |
||||
} |
||||
|
||||
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) |
||||
{ |
||||
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); |
||||
|
||||
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; |
||||
|
||||
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()); |
||||
} |
||||
|
||||
public override void Stop() |
||||
{ |
||||
if (debugger.IsDebugging) { |
||||
debugger.Stop(); |
||||
} |
||||
} |
||||
|
||||
public override void Dispose() |
||||
{ |
||||
Stop(); |
||||
try { |
||||
File.Delete(resultsFileName); |
||||
} catch { } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
// 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.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
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) |
||||
return false; |
||||
|
||||
foreach (ProjectItem item in project.Items) { |
||||
if (item.IsMSTestAssemblyReference()) { |
||||
return true; |
||||
} |
||||
} |
||||
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() |
||||
{ |
||||
return new MSTestDebugger(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// 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.Core; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public static class MSTestOptions |
||||
{ |
||||
static Properties properties = PropertyService.Get("MSTestOptions", new Properties()); |
||||
|
||||
public static string MSTestPath { |
||||
get { return properties.Get<string>("MSTestPath", GetDefaultMSTestPath()); } |
||||
set { properties.Set("MSTestPath", value); } |
||||
} |
||||
|
||||
static string GetDefaultMSTestPath() |
||||
{ |
||||
return Path.Combine( |
||||
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), |
||||
@"Microsoft Visual Studio 10.0\Common7\IDE\mstest.exe"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
<gui:OptionPanel |
||||
x:Class="ICSharpCode.MSTest.MSTestOptionsPanel" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:sd="clr-namespace:ICSharpCode.SharpDevelop" |
||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"> |
||||
<StackPanel> |
||||
<GroupBox Header="MS Test"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto"/> |
||||
<ColumnDefinition Width="*"/> |
||||
<ColumnDefinition Width="Auto"/> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
<Label Content="Path:"/> |
||||
<TextBox |
||||
Grid.Column="1" |
||||
Text="{Binding MSTestPath}"/> |
||||
<Button |
||||
Grid.Column="2" |
||||
Content="..." |
||||
Command="{Binding BrowseCommand}" |
||||
Padding="4, 0" |
||||
Margin="4,0"/> |
||||
</Grid> |
||||
</GroupBox> |
||||
</StackPanel> |
||||
</gui:OptionPanel> |
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// 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.ComponentModel; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Widgets; |
||||
using Microsoft.Win32; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public partial class MSTestOptionsPanel : OptionPanel, INotifyPropertyChanged |
||||
{ |
||||
string msTestPath; |
||||
bool changed; |
||||
|
||||
public MSTestOptionsPanel() |
||||
{ |
||||
InitializeComponent(); |
||||
BrowseCommand = new RelayCommand(Browse); |
||||
msTestPath = MSTestOptions.MSTestPath; |
||||
DataContext = this; |
||||
} |
||||
|
||||
public ICommand BrowseCommand { get; private set; } |
||||
|
||||
void Browse() |
||||
{ |
||||
var dialog = new OpenFileDialog(); |
||||
if (dialog.ShowDialog() ?? false) { |
||||
MSTestPath = dialog.FileName; |
||||
} |
||||
} |
||||
|
||||
public string MSTestPath { |
||||
get { return msTestPath; } |
||||
set { |
||||
msTestPath = value; |
||||
changed = true; |
||||
OnPropertyChanged("MSTestPath"); |
||||
} |
||||
} |
||||
|
||||
public override bool SaveOptions() |
||||
{ |
||||
if (changed) { |
||||
MSTestOptions.MSTestPath = msTestPath; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged; |
||||
|
||||
void OnPropertyChanged(string name) |
||||
{ |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestQualifiedClassName |
||||
{ |
||||
public MSTestQualifiedClassName(string qualifiedClassName) |
||||
{ |
||||
ClassName = GetClassName(qualifiedClassName); |
||||
} |
||||
|
||||
string GetClassName(string qualifiedClassName) |
||||
{ |
||||
int index = qualifiedClassName.IndexOf(','); |
||||
if (index > 0) { |
||||
return qualifiedClassName.Substring(0, index); |
||||
} |
||||
return qualifiedClassName; |
||||
} |
||||
|
||||
public string ClassName { get; private set; } |
||||
|
||||
public string GetQualifiedMethodName(string methodName) |
||||
{ |
||||
return String.Format("{0}.{1}", ClassName, methodName); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
// 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.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestResult |
||||
{ |
||||
public MSTestResult(string id) |
||||
{ |
||||
this.Id = id; |
||||
} |
||||
|
||||
public string Id { get; private set; } |
||||
public string Name { get; private set; } |
||||
public TestResultType ResultType { get; private set; } |
||||
public string StackTrace { get; set; } |
||||
public string Message { get; set; } |
||||
|
||||
public void UpdateTestName(string qualifiedClassName, string methodName) |
||||
{ |
||||
UpdateTestName(new MSTestQualifiedClassName(qualifiedClassName), methodName); |
||||
} |
||||
|
||||
public void UpdateTestName(MSTestQualifiedClassName qualifiedClassName, string methodName) |
||||
{ |
||||
this.Name = qualifiedClassName.GetQualifiedMethodName(methodName); |
||||
} |
||||
|
||||
public void UpdateResult(string result) |
||||
{ |
||||
if (result == "Passed") { |
||||
this.ResultType = TestResultType.Success; |
||||
} else if (result == "Failed") { |
||||
this.ResultType = TestResultType.Failure; |
||||
} |
||||
} |
||||
|
||||
public bool IsError { |
||||
get { return ResultType == TestResultType.Failure; } |
||||
} |
||||
|
||||
public TestResult ToTestResult() |
||||
{ |
||||
return new TestResult(Name) { |
||||
ResultType = ResultType, |
||||
Message = GetMessage(), |
||||
StackTrace = StackTrace, |
||||
StackTraceFilePosition = GetStackTraceFilePosition() |
||||
}; |
||||
} |
||||
|
||||
string GetMessage() |
||||
{ |
||||
if (String.IsNullOrEmpty(Message)) |
||||
return String.Empty; |
||||
|
||||
int index = Message.IndexOf('\n'); |
||||
if (index > 0) { |
||||
return Message.Substring(index + 1); |
||||
} |
||||
return Message; |
||||
} |
||||
|
||||
FilePosition GetStackTraceFilePosition() |
||||
{ |
||||
if (!String.IsNullOrEmpty(StackTrace)) { |
||||
return ParseFilePositionFromStackTrace(); |
||||
} |
||||
return FilePosition.Empty; |
||||
} |
||||
|
||||
FilePosition ParseFilePositionFromStackTrace() |
||||
{ |
||||
FileLineReference fileLineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(StackTrace, true); |
||||
if (fileLineRef != null) { |
||||
return CreateFilePosition(fileLineRef); |
||||
} |
||||
return FilePosition.Empty; |
||||
} |
||||
|
||||
FilePosition CreateFilePosition(FileLineReference fileLineRef) |
||||
{ |
||||
string fileName = Path.GetFullPath(fileLineRef.FileName); |
||||
return new FilePosition(fileName, fileLineRef.Line, fileLineRef.Column + 1); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
// 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.Xml; |
||||
|
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestResults : List<TestResult> |
||||
{ |
||||
Dictionary<string, MSTestResult> testDefinitions = new Dictionary<string, MSTestResult>(); |
||||
|
||||
public MSTestResults(string fileName) |
||||
: this(new XmlTextReader(fileName)) |
||||
{ |
||||
} |
||||
|
||||
public MSTestResults(XmlTextReader reader) |
||||
{ |
||||
ReadResults(reader); |
||||
} |
||||
|
||||
void ReadResults(XmlTextReader reader) |
||||
{ |
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.Element: |
||||
if (reader.Name == "UnitTest") { |
||||
ReadUnitTest(reader); |
||||
} else if (reader.Name == "UnitTestResult") { |
||||
ReadUnitTestResult(reader); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ReadUnitTest(XmlTextReader reader) |
||||
{ |
||||
var testResult = new MSTestResult(reader.GetAttribute("id")); |
||||
testDefinitions.Add(testResult.Id, testResult); |
||||
|
||||
if (reader.ReadToDescendant("TestMethod")) { |
||||
testResult.UpdateTestName(reader.GetAttribute("className"), reader.GetAttribute("name")); |
||||
} |
||||
} |
||||
|
||||
void ReadUnitTestResult(XmlTextReader reader) |
||||
{ |
||||
string testId = reader.GetAttribute("testId"); |
||||
MSTestResult testResult = FindTestResult(testId); |
||||
if (testResult != null) { |
||||
testResult.UpdateResult(reader.GetAttribute("outcome")); |
||||
if (testResult.IsError) { |
||||
ReadErrorInformation(testResult, reader); |
||||
} |
||||
Add(testResult.ToTestResult()); |
||||
} |
||||
} |
||||
|
||||
void ReadErrorInformation(MSTestResult testResult, XmlTextReader reader) |
||||
{ |
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.EndElement: |
||||
if (reader.Name == "UnitTestResult") { |
||||
return; |
||||
} |
||||
break; |
||||
case XmlNodeType.Element: |
||||
if (reader.Name == "Message") { |
||||
testResult.Message = reader.ReadElementContentAsString(); |
||||
} else if (reader.Name == "StackTrace") { |
||||
testResult.StackTrace = reader.ReadElementContentAsString(); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
MSTestResult FindTestResult(string testId) |
||||
{ |
||||
MSTestResult testResult = null; |
||||
testDefinitions.TryGetValue(testId, out testResult); |
||||
return testResult; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// 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 MSTestResultsFileName |
||||
{ |
||||
public MSTestResultsFileName(SelectedTests selectedTests) |
||||
{ |
||||
FileName = GetFileName(selectedTests); |
||||
} |
||||
|
||||
public string FileName { get; private set; } |
||||
|
||||
string GetFileName(SelectedTests selectedTests) |
||||
{ |
||||
return Path.Combine( |
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), |
||||
"Temp", |
||||
selectedTests.Project.Name + "-Results.trx"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
// 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.Diagnostics; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.SharpDevelop.Util; |
||||
using ICSharpCode.UnitTesting; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public class MSTestRunner : TestRunnerBase |
||||
{ |
||||
IUnitTestProcessRunner processRunner; |
||||
IFileSystem fileSystem; |
||||
IUnitTestMessageService messageService; |
||||
string resultsFileName; |
||||
|
||||
public MSTestRunner() |
||||
: this(new UnitTestProcessRunner(), |
||||
new UnitTestFileService(), |
||||
new UnitTestMessageService()) |
||||
{ |
||||
} |
||||
|
||||
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) |
||||
{ |
||||
resultsFileName = new MSTestResultsFileName(selectedTests).FileName; |
||||
CreateDirectoryForResultsFile(); |
||||
var mstestApplication = new MSTestApplication(selectedTests, resultsFileName); |
||||
return mstestApplication.ProcessStartInfo; |
||||
} |
||||
|
||||
void Start(ProcessStartInfo processStartInfo) |
||||
{ |
||||
LogCommandLine(processStartInfo); |
||||
|
||||
if (FileExists(processStartInfo.FileName)) { |
||||
processRunner.WorkingDirectory = processStartInfo.WorkingDirectory; |
||||
processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments); |
||||
} else { |
||||
ShowApplicationDoesNotExistMessage(processStartInfo.FileName); |
||||
} |
||||
} |
||||
|
||||
void CreateDirectoryForResultsFile() |
||||
{ |
||||
string path = Path.GetDirectoryName(resultsFileName); |
||||
if (!Directory.Exists(path)) { |
||||
Directory.CreateDirectory(path); |
||||
} |
||||
} |
||||
|
||||
bool FileExists(string fileName) |
||||
{ |
||||
return fileSystem.FileExists(fileName); |
||||
} |
||||
|
||||
void ShowApplicationDoesNotExistMessage(string fileName) |
||||
{ |
||||
string resourceString = "${res:ICSharpCode.UnitTesting.TestRunnerNotFoundMessageFormat}"; |
||||
messageService.ShowFormattedErrorMessage(resourceString, fileName); |
||||
} |
||||
|
||||
public override void Stop() |
||||
{ |
||||
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); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// 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.Project; |
||||
|
||||
namespace ICSharpCode.MSTest |
||||
{ |
||||
public static class ProjectItemExtensions |
||||
{ |
||||
public static bool IsMSTestAssemblyReference(this ProjectItem item) |
||||
{ |
||||
var referenceItem = item as ReferenceProjectItem; |
||||
if (referenceItem == null) |
||||
return false; |
||||
|
||||
return IsMSTestAssemblyReference(referenceItem); |
||||
} |
||||
|
||||
public static bool IsMSTestAssemblyReference(this ReferenceProjectItem item) |
||||
{ |
||||
return String.Equals( |
||||
item.ShortName, |
||||
"Microsoft.VisualStudio.QualityTools.UnitTestFramework", |
||||
StringComparison.OrdinalIgnoreCase); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MSTest.SharpDevelop")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("MSTest.SharpDevelop")] |
||||
[assembly: AssemblyCopyright("Copyright 2012")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0")] |
@ -1,77 +0,0 @@
@@ -1,77 +0,0 @@
|
||||
//// 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 System.Linq;
|
||||
//
|
||||
//using ICSharpCode.Core;
|
||||
//using ICSharpCode.SharpDevelop.Gui.OptionPanels;
|
||||
//using ICSharpCode.SharpDevelop.Project;
|
||||
//using ICSharpCode.SharpDevelop.Project.Commands;
|
||||
//
|
||||
//namespace ICSharpCode.AspNet.Mvc
|
||||
//{
|
||||
// public class ViewInBrowser : AbstractMenuCommand
|
||||
// {
|
||||
// public override void Run()
|
||||
// {
|
||||
// var node = ProjectBrowserPad.Instance.SelectedNode as FileNode;
|
||||
// if (node == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// var project = ProjectService.CurrentProject as CompilableProject;
|
||||
// if (project == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!project.IsWebProject) {
|
||||
// MessageService.ShowError("${res:ProjectComponent.ContextMenu.NotAWebProject}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (!WebProjectService.IsIISOrIISExpressInstalled) {
|
||||
// MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.IISNotFound}");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// string fileName = node.FileName;
|
||||
//
|
||||
//// // set project options
|
||||
//// project.StartAction = StartAction.StartURL;
|
||||
//// string directoryName = Path.GetDirectoryName(project.FileName) + "\\";
|
||||
//// project.StartUrl = fileName.Replace(directoryName, "/").Replace("\\", "/");
|
||||
//
|
||||
// // set web server options
|
||||
// string projectName = project.Name;
|
||||
// WebProjectOptions existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName);
|
||||
//
|
||||
// var options = new WebProjectOptions {
|
||||
// Data = new WebProjectDebugData {
|
||||
// WebServer = WebProjectService.IsIISExpressInstalled ? WebServer.IISExpress : WebServer.IIS,
|
||||
// Port = (existingOptions != null && existingOptions.Data != null) ? existingOptions.Data.Port : "8080", //TODO: port collision detection
|
||||
// ProjectUrl = string.Format("{0}/{1}", WebBehavior.LocalHost, project.Name)
|
||||
// },
|
||||
// ProjectName = projectName
|
||||
// };
|
||||
//
|
||||
// if (options.Data.WebServer == WebServer.IISExpress) {
|
||||
// options.Data.ProjectUrl = string.Format(
|
||||
// @"{0}:{1}/{2}", WebBehavior.LocalHost, options.Data.Port, projectName);
|
||||
// }
|
||||
//
|
||||
// WebProjectsOptions.Instance.SetWebProjectOptions(projectName, options);
|
||||
//
|
||||
// // create virtual directory
|
||||
// string error = WebProjectService.CreateVirtualDirectory(
|
||||
// options.Data.WebServer,
|
||||
// projectName,
|
||||
// Path.GetDirectoryName(ProjectService.CurrentProject.FileName));
|
||||
// LoggingService.Info(error ?? string.Empty);
|
||||
//
|
||||
// // RunProject
|
||||
// new RunProject().Run();
|
||||
// }
|
||||
// }
|
||||
//}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,145 @@
@@ -0,0 +1,145 @@
|
||||
// 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; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
|
||||
namespace ICSharpCode.XamlBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of XamlCompilationUnit.
|
||||
/// </summary>
|
||||
public class XamlCompilationUnit : DefaultCompilationUnit |
||||
{ |
||||
public XamlCompilationUnit(IProjectContent projectContent) |
||||
: base(projectContent) |
||||
{ |
||||
} |
||||
|
||||
public NodeWrapper TreeRootNode { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Creates a IReturnType looking for a class referenced in XAML.
|
||||
/// </summary>
|
||||
/// <param name="xmlNamespace">The XML namespace</param>
|
||||
/// <param name="className">The class name</param>
|
||||
/// <returns>A new IReturnType that will search the referenced type on demand.</returns>
|
||||
public IReturnType CreateType(string xmlNamespace, string className) |
||||
{ |
||||
if (string.IsNullOrEmpty(className) || className.Contains(".")) |
||||
return null; |
||||
|
||||
if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase)) { |
||||
return CreateClrNamespaceType(this.ProjectContent, xmlNamespace, className); |
||||
} else { |
||||
return new XamlClassReturnType(this, xmlNamespace, className); |
||||
} |
||||
} |
||||
|
||||
static IReturnType CreateClrNamespaceType(IProjectContent pc, string xmlNamespace, string className) |
||||
{ |
||||
string namespaceName = GetNamespaceNameFromClrNamespace(xmlNamespace); |
||||
return new GetClassReturnType(pc, namespaceName + "." + className, 0); |
||||
} |
||||
|
||||
static string GetNamespaceNameFromClrNamespace(string xmlNamespace) |
||||
{ |
||||
string namespaceName = xmlNamespace.Substring("clr-namespace:".Length); |
||||
int pos = namespaceName.IndexOf(';'); |
||||
if (pos >= 0) { |
||||
// we expect that the target type is also a reference of the project, so we
|
||||
// can ignore the assembly part after the ;
|
||||
namespaceName = namespaceName.Substring(0, pos); |
||||
} |
||||
return namespaceName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds a type referenced in XAML.
|
||||
/// </summary>
|
||||
/// <param name="xmlNamespace">The XML namespace</param>
|
||||
/// <param name="className">The class name</param>
|
||||
/// <returns>Returns the referenced type, or null if it cannot be found.</returns>
|
||||
public IReturnType FindType(string xmlNamespace, string className) |
||||
{ |
||||
return FindType(this.ProjectContent, xmlNamespace, className); |
||||
} |
||||
|
||||
public static IReturnType FindType(IProjectContent pc, string xmlNamespace, string className) |
||||
{ |
||||
if (pc == null) |
||||
throw new ArgumentNullException("pc"); |
||||
if (xmlNamespace == null || className == null) |
||||
return null; |
||||
if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase)) { |
||||
return CreateClrNamespaceType(pc, xmlNamespace, className); |
||||
} |
||||
else { |
||||
IReturnType type = FindTypeInAssembly(pc, xmlNamespace, className); |
||||
if (type != null) |
||||
return type; |
||||
foreach (IProjectContent p in pc.ThreadSafeGetReferencedContents()) { |
||||
type = FindTypeInAssembly(p, xmlNamespace, className); |
||||
if (type != null) |
||||
return type; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
static IReturnType FindTypeInAssembly(IProjectContent projectContent, string xmlNamespace, string className) |
||||
{ |
||||
foreach (IAttribute att in projectContent.GetAssemblyAttributes()) { |
||||
if (att.PositionalArguments.Count == 2 |
||||
&& att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") { |
||||
string namespaceName = att.PositionalArguments[1] as string; |
||||
if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) { |
||||
IClass c = projectContent.GetClass(namespaceName + "." + className, 0); |
||||
if (c != null) |
||||
return c.DefaultReturnType; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static IEnumerable<IClass> GetNamespaceMembers(IProjectContent pc, string xmlNamespace) |
||||
{ |
||||
if (pc == null) |
||||
throw new ArgumentNullException("pc"); |
||||
|
||||
if (!string.IsNullOrEmpty(xmlNamespace)) { |
||||
if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase)) |
||||
return pc.GetNamespaceContents(GetNamespaceNameFromClrNamespace(xmlNamespace)).OfType<IClass>(); |
||||
else { |
||||
var list = new List<ICompletionEntry>(); |
||||
AddNamespaceMembersInAssembly(pc, xmlNamespace, list); |
||||
foreach (IProjectContent p in pc.ThreadSafeGetReferencedContents()) { |
||||
AddNamespaceMembersInAssembly(p, xmlNamespace, list); |
||||
} |
||||
return list.OfType<IClass>(); |
||||
} |
||||
} |
||||
|
||||
return Enumerable.Empty<IClass>(); |
||||
} |
||||
|
||||
static void AddNamespaceMembersInAssembly(IProjectContent projectContent, string xmlNamespace, List<ICompletionEntry> list) |
||||
{ |
||||
foreach (IAttribute att in projectContent.GetAssemblyAttributes()) { |
||||
if (att.PositionalArguments.Count == 2 |
||||
&& att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") { |
||||
string namespaceName = att.PositionalArguments[1] as string; |
||||
if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) { |
||||
projectContent.AddNamespaceContents(list, namespaceName, projectContent.Language, false); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
// 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.Linq; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
using System.Security; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using System.Windows.Interop; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.TextFormatting; |
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
using ICSharpCode.AvalonEdit.Utils; |
||||
using Draw = System.Drawing; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.Editing |
||||
{ |
||||
/// <summary>
|
||||
/// Native API required for IME support.
|
||||
/// </summary>
|
||||
static class ImeNativeWrapper |
||||
{ |
||||
[StructLayout(LayoutKind.Sequential)] |
||||
struct CompositionForm |
||||
{ |
||||
public int dwStyle; |
||||
public POINT ptCurrentPos; |
||||
public RECT rcArea; |
||||
} |
||||
|
||||
[StructLayout(LayoutKind.Sequential)] |
||||
struct POINT |
||||
{ |
||||
public int x; |
||||
public int y; |
||||
} |
||||
|
||||
[StructLayout(LayoutKind.Sequential)] |
||||
struct RECT |
||||
{ |
||||
public int left; |
||||
public int top; |
||||
public int right; |
||||
public int bottom; |
||||
} |
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] |
||||
class LOGFONT |
||||
{ |
||||
public int lfHeight = 0; |
||||
public int lfWidth = 0; |
||||
public int lfEscapement = 0; |
||||
public int lfOrientation = 0; |
||||
public int lfWeight = 0; |
||||
public byte lfItalic = 0; |
||||
public byte lfUnderline = 0; |
||||
public byte lfStrikeOut = 0; |
||||
public byte lfCharSet = 0; |
||||
public byte lfOutPrecision = 0; |
||||
public byte lfClipPrecision = 0; |
||||
public byte lfQuality = 0; |
||||
public byte lfPitchAndFamily = 0; |
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string lfFaceName = null; |
||||
} |
||||
|
||||
const int CPS_CANCEL = 0x4; |
||||
const int NI_COMPOSITIONSTR = 0x15; |
||||
const int GCS_COMPSTR = 0x0008; |
||||
|
||||
public const int WM_IME_COMPOSITION = 0x10F; |
||||
public const int WM_INPUTLANGCHANGE = 0x51; |
||||
|
||||
[DllImport("imm32.dll")] |
||||
static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hIMC); |
||||
[DllImport("imm32.dll")] |
||||
static extern IntPtr ImmGetContext(IntPtr hWnd); |
||||
[DllImport("imm32.dll")] |
||||
[return: MarshalAs(UnmanagedType.Bool)] |
||||
static extern bool ImmNotifyIME(IntPtr hIMC, int dwAction, int dwIndex, int dwValue = 0); |
||||
[DllImport("imm32.dll")] |
||||
[return: MarshalAs(UnmanagedType.Bool)] |
||||
static extern bool ImmReleaseContext(IntPtr hWnd, IntPtr hIMC); |
||||
[DllImport("imm32.dll")] |
||||
[return: MarshalAs(UnmanagedType.Bool)] |
||||
static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref CompositionForm form); |
||||
[DllImport("imm32.dll")] |
||||
[return: MarshalAs(UnmanagedType.Bool)] |
||||
static extern bool ImmSetCompositionFont(IntPtr hIMC, ref LOGFONT font); |
||||
[DllImport("imm32.dll")] |
||||
[return: MarshalAs(UnmanagedType.Bool)] |
||||
static extern bool ImmGetCompositionFont(IntPtr hIMC, out LOGFONT font); |
||||
|
||||
public static IntPtr AssociateContext(HwndSource source, IntPtr hIMC) |
||||
{ |
||||
if (source == null) |
||||
throw new ArgumentNullException("source"); |
||||
return ImmAssociateContext(source.Handle, hIMC); |
||||
} |
||||
|
||||
public static bool NotifyIme(IntPtr hIMC) |
||||
{ |
||||
return ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL); |
||||
} |
||||
|
||||
public static IntPtr GetContext(HwndSource source) |
||||
{ |
||||
if (source == null) |
||||
return IntPtr.Zero; |
||||
return ImmGetContext(source.Handle); |
||||
} |
||||
|
||||
public static bool ReleaseContext(HwndSource source, IntPtr hIMC) |
||||
{ |
||||
return source != null && hIMC != IntPtr.Zero && ImmReleaseContext(source.Handle, hIMC); |
||||
} |
||||
|
||||
public static bool SetCompositionWindow(HwndSource source, IntPtr hIMC, TextArea textArea) |
||||
{ |
||||
if (textArea == null) |
||||
throw new ArgumentNullException("textArea"); |
||||
Rect textViewBounds = textArea.TextView.GetBounds(); |
||||
Rect characterBounds = textArea.TextView.GetCharacterBounds(textArea.Caret.Position, source); |
||||
if (source != null) { |
||||
Matrix transformToDevice = source.CompositionTarget.TransformToDevice; |
||||
textViewBounds.Transform(transformToDevice); |
||||
characterBounds.Transform(transformToDevice); |
||||
} |
||||
CompositionForm form = new CompositionForm(); |
||||
form.dwStyle = 0x0020; |
||||
form.ptCurrentPos.x = (int)Math.Max(characterBounds.Left, textViewBounds.Left); |
||||
form.ptCurrentPos.y = (int)Math.Max(characterBounds.Top, textViewBounds.Top); |
||||
form.rcArea.left = (int)textViewBounds.Left; |
||||
form.rcArea.top = (int)textViewBounds.Top; |
||||
form.rcArea.right = (int)textViewBounds.Right; |
||||
form.rcArea.bottom = (int)textViewBounds.Bottom; |
||||
return ImmSetCompositionWindow(hIMC, ref form); |
||||
} |
||||
|
||||
public static bool SetCompositionFont(HwndSource source, IntPtr hIMC, TextArea textArea) |
||||
{ |
||||
if (textArea == null) |
||||
throw new ArgumentNullException("textArea"); |
||||
// LOGFONT font = new LOGFONT();
|
||||
// ImmGetCompositionFont(hIMC, out font);
|
||||
return false; |
||||
} |
||||
|
||||
static Rect GetBounds(this TextView textView) |
||||
{ |
||||
Point location = textView.TranslatePoint(new Point(0,0), textView); |
||||
return new Rect(location, new Size(textView.ActualWidth, textView.ActualHeight)); |
||||
} |
||||
|
||||
static readonly Rect EMPTY_RECT = new Rect(0, 0, 0, 0); |
||||
|
||||
static Rect GetCharacterBounds(this TextView textView, TextViewPosition pos, HwndSource source) |
||||
{ |
||||
VisualLine vl = textView.GetVisualLine(pos.Line); |
||||
if (vl == null) return EMPTY_RECT; |
||||
TextLine line = vl.GetTextLine(pos.VisualColumn); |
||||
double offset = vl.GetTextLineVisualYPosition(line, VisualYPosition.LineTop) - textView.ScrollOffset.Y; |
||||
Rect r = line.GetTextBounds(pos.VisualColumn, 1).First().Rectangle; |
||||
r.Offset(-textView.ScrollOffset.X, offset); |
||||
// this may happen during layout changes in AvalonDock, so we just return an empty rectangle
|
||||
// in those cases. It should be refreshed immediately.
|
||||
if (!source.RootVisual.IsAncestorOf(textView)) return EMPTY_RECT; |
||||
Point pointOnRootVisual = textView.TransformToAncestor(source.RootVisual).Transform(r.Location); |
||||
Point pointOnHwnd = pointOnRootVisual.TransformToDevice(source.RootVisual); |
||||
r.Location = pointOnHwnd; |
||||
return r; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
// 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.ComponentModel; |
||||
using System.Linq; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
using System.Security; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Interop; |
||||
using System.Windows.Media; |
||||
using System.Windows.Media.TextFormatting; |
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
|
||||
namespace ICSharpCode.AvalonEdit.Editing |
||||
{ |
||||
class ImeSupport : IDisposable |
||||
{ |
||||
TextArea textArea; |
||||
IntPtr currentContext; |
||||
IntPtr previousContext; |
||||
HwndSource hwndSource; |
||||
|
||||
public ImeSupport(TextArea textArea) |
||||
{ |
||||
if (textArea == null) |
||||
throw new ArgumentNullException("textArea"); |
||||
this.textArea = textArea; |
||||
InputMethod.SetIsInputMethodSuspended(this.textArea, true); |
||||
textArea.GotKeyboardFocus += TextAreaGotKeyboardFocus; |
||||
textArea.LostKeyboardFocus += TextAreaLostKeyboardFocus; |
||||
textArea.OptionChanged += TextAreaOptionChanged; |
||||
currentContext = IntPtr.Zero; |
||||
previousContext = IntPtr.Zero; |
||||
} |
||||
|
||||
void TextAreaOptionChanged(object sender, PropertyChangedEventArgs e) |
||||
{ |
||||
if (e.PropertyName == "EnableImeSupport" && textArea.IsKeyboardFocusWithin) { |
||||
CreateContext(); |
||||
} |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
if (textArea != null) { |
||||
textArea.GotKeyboardFocus -= TextAreaGotKeyboardFocus; |
||||
textArea.LostKeyboardFocus -= TextAreaLostKeyboardFocus; |
||||
textArea = null; |
||||
} |
||||
ClearContext(); |
||||
} |
||||
|
||||
void ClearContext() |
||||
{ |
||||
if (hwndSource != null) { |
||||
hwndSource.RemoveHook(WndProc); |
||||
ImeNativeWrapper.AssociateContext(hwndSource, previousContext); |
||||
previousContext = IntPtr.Zero; |
||||
ImeNativeWrapper.ReleaseContext(hwndSource, currentContext); |
||||
hwndSource = null; |
||||
currentContext = IntPtr.Zero; |
||||
} |
||||
} |
||||
|
||||
void TextAreaGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) |
||||
{ |
||||
if (this.textArea == null) |
||||
return; |
||||
if (e.OriginalSource != this.textArea) |
||||
return; |
||||
CreateContext(); |
||||
} |
||||
|
||||
void CreateContext() |
||||
{ |
||||
if (this.textArea == null) |
||||
return; |
||||
if (!textArea.Options.EnableImeSupport) |
||||
return; |
||||
hwndSource = (HwndSource)PresentationSource.FromVisual(this.textArea); |
||||
if (hwndSource != null) { |
||||
currentContext = ImeNativeWrapper.GetContext(hwndSource); |
||||
previousContext = ImeNativeWrapper.AssociateContext(hwndSource, currentContext); |
||||
// ImeNativeWrapper.SetCompositionFont(hwndSource, currentContext, textArea);
|
||||
hwndSource.AddHook(WndProc); |
||||
} |
||||
} |
||||
|
||||
void TextAreaLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) |
||||
{ |
||||
if (e.OriginalSource != this.textArea) |
||||
return; |
||||
if (currentContext != IntPtr.Zero) |
||||
ImeNativeWrapper.NotifyIme(currentContext); |
||||
ClearContext(); |
||||
} |
||||
|
||||
IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) |
||||
{ |
||||
switch (msg) { |
||||
case ImeNativeWrapper.WM_INPUTLANGCHANGE: |
||||
ClearContext(); |
||||
CreateContext(); |
||||
break; |
||||
case ImeNativeWrapper.WM_IME_COMPOSITION: |
||||
UpdateCompositionWindow(); |
||||
break; |
||||
} |
||||
return IntPtr.Zero; |
||||
} |
||||
|
||||
public void UpdateCompositionWindow() |
||||
{ |
||||
if (currentContext != IntPtr.Zero && textArea != null) { |
||||
ImeNativeWrapper.SetCompositionWindow(hwndSource, currentContext, textArea); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,146 @@
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0"?> |
||||
<SyntaxDefinition name="PowerShell" extensions=".ps1;.psm1;.psd1" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> |
||||
<Color name="Comment" foreground="Green" exampleText="// comment" /> |
||||
<Color name="String" foreground="Blue" exampleText="string text = "Hello, World!""/> |
||||
<Color name="Char" foreground="Magenta" exampleText="char linefeed = '\n';"/> |
||||
<Color name="Punctuation" exampleText="a(b.c);" /> |
||||
<Color name="NumberLiteral" foreground="DarkBlue" exampleText="3.1415f"/> |
||||
<Color name="Keywords" fontWeight="bold" foreground="Blue" exampleText="if (a)"/> |
||||
<Color name="Variable" foreground="Maroon" exampleText="$param = 1" /> |
||||
<Color name="ExceptionKeywords" fontWeight="bold" foreground="Teal" /> |
||||
<Color name="GotoKeywords" foreground="Navy" /> |
||||
<Color name="ReferenceTypes" foreground="Red" /> |
||||
<Color name="Command" fontWeight="bold" foreground="MidnightBlue" /> |
||||
<Color name="Operators" foreground="#FF8515EA" exampleText="-eq"/> |
||||
|
||||
<RuleSet ignoreCase="true"> |
||||
<Span color="Comment"> |
||||
<Begin>\#</Begin> |
||||
</Span> |
||||
|
||||
<Span color="Comment" multiline="true"> |
||||
<Begin><\#</Begin> |
||||
<End>\#></End> |
||||
</Span> |
||||
|
||||
<Span color="String"> |
||||
<Begin>"</Begin> |
||||
<End>"</End> |
||||
<RuleSet> |
||||
<!-- span for escape sequences --> |
||||
<Span begin="\\" end="."/> |
||||
</RuleSet> |
||||
</Span> |
||||
|
||||
<Span color="Char"> |
||||
<Begin>'</Begin> |
||||
<End>'</End> |
||||
<RuleSet> |
||||
<!-- span for escape sequences --> |
||||
<Span begin="\\" end="."/> |
||||
</RuleSet> |
||||
</Span> |
||||
|
||||
<Span color="String" multiline="true"> |
||||
<Begin color="String">@"</Begin> |
||||
<End>"@</End> |
||||
<RuleSet> |
||||
<!-- span for escape sequences --> |
||||
<Span begin='""' end=""/> |
||||
</RuleSet> |
||||
</Span> |
||||
|
||||
<Keywords color="Keywords"> |
||||
<Word>while</Word> |
||||
<Word>param</Word> |
||||
<Word>end</Word> |
||||
<Word>define</Word> |
||||
<Word>else</Word> |
||||
<Word>from</Word> |
||||
<Word>foreach</Word> |
||||
<Word>var</Word> |
||||
<Word>dynamicparam</Word> |
||||
<Word>filter</Word> |
||||
<Word>dp</Word> |
||||
<Word>until</Word> |
||||
<Word>for</Word> |
||||
<Word>exit</Word> |
||||
<Word>switch</Word> |
||||
<Word>process</Word> |
||||
<Word>begin</Word> |
||||
<Word>elseif</Word> |
||||
<Word>if</Word> |
||||
<Word>in</Word> |
||||
<Word>data</Word> |
||||
<Word>class</Word> |
||||
<Word>using</Word> |
||||
<Word>function</Word> |
||||
</Keywords> |
||||
|
||||
<Keywords color="ExceptionKeywords"> |
||||
<Word>catch</Word> |
||||
<Word>finally</Word> |
||||
<Word>throw</Word> |
||||
<Word>trap</Word> |
||||
<Word>try</Word> |
||||
</Keywords> |
||||
|
||||
<Keywords color="GotoKeywords"> |
||||
<Word>break</Word> |
||||
<Word>continue</Word> |
||||
<Word>return</Word> |
||||
</Keywords> |
||||
|
||||
<Keywords color="ReferenceTypes"> |
||||
<Word>class</Word> |
||||
</Keywords> |
||||
|
||||
<Keywords color="Operators"> |
||||
<Word>-not</Word> |
||||
<Word>-band</Word> |
||||
<Word>-bor</Word> |
||||
<Word>-replace</Word> |
||||
<Word>-ireplace</Word> |
||||
<Word>-creplace</Word> |
||||
<Word>-and</Word> |
||||
<Word>-or</Word> |
||||
<Word>-is</Word> |
||||
<Word>-isnot</Word> |
||||
<Word>-as</Word> |
||||
<Word>-lt</Word> |
||||
<Word>-le</Word> |
||||
<Word>-gt</Word> |
||||
<Word>-ge</Word> |
||||
<Word>-eq</Word> |
||||
<Word>-ne</Word> |
||||
<Word>-contains</Word> |
||||
<Word>-notcontains</Word> |
||||
<Word>-like</Word> |
||||
<Word>-notlike</Word> |
||||
<Word>-match</Word> |
||||
<Word>-notmatch</Word> |
||||
</Keywords> |
||||
|
||||
<Rule color="Variable"> |
||||
\$[\d\w_]+ |
||||
</Rule> |
||||
|
||||
<Rule color="Command"> |
||||
[\w]+-[\w]+ |
||||
</Rule> |
||||
|
||||
<!-- Digits --> |
||||
<Rule color="NumberLiteral"> |
||||
\b0[xX][0-9a-fA-F]+ # hex number |
||||
| |
||||
( \b\d+(\.[0-9]+)? #number with optional floating point |
||||
| \.[0-9]+ #or just starting with floating point |
||||
) |
||||
([eE][+-]?[0-9]+)? # optional exponent |
||||
</Rule> |
||||
|
||||
<Rule color="Punctuation"> |
||||
[?,.;()\[\]{}+\-/%*<>^+~!|&]+ |
||||
</Rule> |
||||
</RuleSet> |
||||
</SyntaxDefinition> |
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
public static class ControlFlow |
||||
{ |
||||
public static void EmptyIf(string input, List<string> value, Dictionary<int, string> _headers) |
||||
{ |
||||
if (value.Contains("test")) |
||||
{ |
||||
} |
||||
_headers.Add(2, "result"); |
||||
} |
||||
|
||||
public static void NormalIf(string input, List<string> value, Dictionary<int, string> _headers) |
||||
{ |
||||
if (value.Contains("test")) |
||||
{ |
||||
_headers.Add(1, "result"); |
||||
} |
||||
else |
||||
{ |
||||
_headers.Add(1, "else"); |
||||
} |
||||
_headers.Add(2, "end"); |
||||
} |
||||
|
||||
public static void NormalIf2(string input, List<string> value, Dictionary<int, string> _headers) |
||||
{ |
||||
if (value.Contains("test")) |
||||
{ |
||||
_headers.Add(1, "result"); |
||||
} |
||||
_headers.Add(2, "end"); |
||||
} |
||||
|
||||
public static void NormalIf3(string input, List<string> value, Dictionary<int, string> _headers) |
||||
{ |
||||
if (value.Contains("test")) |
||||
{ |
||||
_headers.Add(1, "result"); |
||||
} |
||||
else |
||||
{ |
||||
_headers.Add(1, "else"); |
||||
} |
||||
} |
||||
|
||||
public static void Test(string input, List<string> value, Dictionary<int, string> _headers) |
||||
{ |
||||
foreach (string current in value) |
||||
{ |
||||
_headers.Add(0, current); |
||||
} |
||||
if (value.Contains("test")) |
||||
{ |
||||
_headers.Add(1, "result"); |
||||
} |
||||
else |
||||
{ |
||||
_headers.Add(1, "else"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.Decompiler.Ast; |
||||
using ICSharpCode.Decompiler.Tests.Helpers; |
||||
using Mono.Cecil; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Decompiler.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class ILTests |
||||
{ |
||||
const string path = "../../Tests/IL"; |
||||
|
||||
[Test] |
||||
public void SequenceOfNestedIfs() |
||||
{ |
||||
Run("SequenceOfNestedIfs.dll", "SequenceOfNestedIfs.Output.cs"); |
||||
} |
||||
|
||||
void Run(string compiledFile, string expectedOutputFile) |
||||
{ |
||||
string expectedOutput = File.ReadAllText(Path.Combine(path, expectedOutputFile)); |
||||
var assembly = AssemblyDefinition.ReadAssembly(Path.Combine(path, compiledFile)); |
||||
AstBuilder decompiler = new AstBuilder(new DecompilerContext(assembly.MainModule)); |
||||
decompiler.AddAssembly(assembly); |
||||
new Helpers.RemoveCompilerAttribute().Run(decompiler.CompilationUnit); |
||||
StringWriter output = new StringWriter(); |
||||
decompiler.GenerateCode(new PlainTextOutput(output)); |
||||
CodeAssert.AreEqual(expectedOutput, output.ToString()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
using System; |
||||
[Serializable] |
||||
public class Material |
||||
{ |
||||
public static implicit operator bool(Material m) |
||||
{ |
||||
return m == null; |
||||
} |
||||
} |
||||
[Serializable] |
||||
public class SequenceOfNestedIfs |
||||
{ |
||||
public bool _clear; |
||||
public Material _material; |
||||
public override bool CheckShader() |
||||
{ |
||||
return false; |
||||
} |
||||
public override void CreateMaterials() |
||||
{ |
||||
if (!this._clear) |
||||
{ |
||||
if (!this.CheckShader()) |
||||
{ |
||||
return; |
||||
} |
||||
this._material = new Material(); |
||||
} |
||||
if (!this._material) |
||||
{ |
||||
if (!this.CheckShader()) |
||||
{ |
||||
return; |
||||
} |
||||
this._material = new Material(); |
||||
} |
||||
if (!this._material) |
||||
{ |
||||
if (!this.CheckShader()) |
||||
{ |
||||
return; |
||||
} |
||||
this._material = new Material(); |
||||
} |
||||
if (!this._material) |
||||
{ |
||||
if (this.CheckShader()) |
||||
{ |
||||
this._material = new Material(); |
||||
} |
||||
} |
||||
} |
||||
} |
Binary file not shown.
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
// Metadata version: v2.0.50727 |
||||
.assembly extern mscorlib |
||||
{ |
||||
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. |
||||
.ver 2:0:0:0 |
||||
} |
||||
|
||||
.assembly SequenceOfNestedIfs |
||||
{ |
||||
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx |
||||
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. |
||||
.hash algorithm 0x00008004 |
||||
.ver 0:0:0:0 |
||||
} |
||||
.module SequenceOfNestedIfs |
||||
// MVID: {DCEC8A87-5679-4EBE-89A3-51274D8B5446} |
||||
.imagebase 0x00400000 |
||||
.file alignment 0x00000200 |
||||
.stackreserve 0x00100000 |
||||
.subsystem 0x0003 // WINDOWS_CUI |
||||
.corflags 0x00000001 // ILONLY |
||||
// Image base: 0x01D60000 |
||||
|
||||
|
||||
// =============== CLASS MEMBERS DECLARATION =================== |
||||
|
||||
.class public auto ansi serializable beforefieldinit Material |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method Material::.ctor |
||||
|
||||
.method public hidebysig specialname static |
||||
bool op_Implicit(class Material m) cil managed |
||||
{ |
||||
// Code size 11 (0xb) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldnull |
||||
IL_0008: ceq |
||||
IL_000a: ret |
||||
} // end of method Material::op_Implicit |
||||
|
||||
} // end of class Material |
||||
|
||||
.class public auto ansi serializable beforefieldinit SequenceOfNestedIfs |
||||
extends [mscorlib]System.Object |
||||
{ |
||||
.field public bool _clear |
||||
.field public class Material _material |
||||
.method public hidebysig specialname rtspecialname |
||||
instance void .ctor() cil managed |
||||
{ |
||||
// Code size 7 (0x7) |
||||
.maxstack 8 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: call instance void [mscorlib]System.Object::.ctor() |
||||
IL_0006: ret |
||||
} // end of method SequenceOfNestedIfs::.ctor |
||||
|
||||
.method public hidebysig virtual instance bool |
||||
CheckShader() cil managed |
||||
{ |
||||
// Code size 2 (0x2) |
||||
.maxstack 8 |
||||
IL_0000: ldc.i4.0 |
||||
IL_0001: ret |
||||
} // end of method SequenceOfNestedIfs::CheckShader |
||||
|
||||
.method public hidebysig virtual instance void |
||||
CreateMaterials() cil managed |
||||
{ |
||||
// Code size 168 (0xa8) |
||||
.maxstack 13 |
||||
IL_0000: ldarg.0 |
||||
IL_0001: ldfld bool SequenceOfNestedIfs::_clear |
||||
IL_0006: brtrue IL_0026 |
||||
|
||||
IL_000b: ldarg.0 |
||||
IL_000c: callvirt instance bool SequenceOfNestedIfs::CheckShader() |
||||
IL_0011: brtrue IL_001b |
||||
|
||||
IL_0016: br IL_00a7 |
||||
|
||||
IL_001b: ldarg.0 |
||||
IL_001c: newobj instance void Material::.ctor() |
||||
IL_0021: stfld class Material SequenceOfNestedIfs::_material |
||||
IL_0026: ldarg.0 |
||||
IL_0027: ldfld class Material SequenceOfNestedIfs::_material |
||||
IL_002c: call bool Material::op_Implicit(class Material) |
||||
IL_0031: brtrue IL_0051 |
||||
|
||||
IL_0036: ldarg.0 |
||||
IL_0037: callvirt instance bool SequenceOfNestedIfs::CheckShader() |
||||
IL_003c: brtrue IL_0046 |
||||
|
||||
IL_0041: br IL_00a7 |
||||
|
||||
IL_0046: ldarg.0 |
||||
IL_0047: newobj instance void Material::.ctor() |
||||
IL_004c: stfld class Material SequenceOfNestedIfs::_material |
||||
IL_0051: ldarg.0 |
||||
IL_0052: ldfld class Material SequenceOfNestedIfs::_material |
||||
IL_0057: call bool Material::op_Implicit(class Material) |
||||
IL_005c: brtrue IL_007c |
||||
|
||||
IL_0061: ldarg.0 |
||||
IL_0062: callvirt instance bool SequenceOfNestedIfs::CheckShader() |
||||
IL_0067: brtrue IL_0071 |
||||
|
||||
IL_006c: br IL_00a7 |
||||
|
||||
IL_0071: ldarg.0 |
||||
IL_0072: newobj instance void Material::.ctor() |
||||
IL_0077: stfld class Material SequenceOfNestedIfs::_material |
||||
IL_007c: ldarg.0 |
||||
IL_007d: ldfld class Material SequenceOfNestedIfs::_material |
||||
IL_0082: call bool Material::op_Implicit(class Material) |
||||
IL_0087: brtrue IL_00a7 |
||||
|
||||
IL_008c: ldarg.0 |
||||
IL_008d: callvirt instance bool SequenceOfNestedIfs::CheckShader() |
||||
IL_0092: brtrue IL_009c |
||||
|
||||
IL_0097: br IL_00a7 |
||||
|
||||
IL_009c: ldarg.0 |
||||
IL_009d: newobj instance void Material::.ctor() |
||||
IL_00a2: stfld class Material SequenceOfNestedIfs::_material |
||||
IL_00a7: ret |
||||
} // end of method SequenceOfNestedIfs::CreateMaterials |
||||
|
||||
} // end of class SequenceOfNestedIfs |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue