818 changed files with 53207 additions and 95761 deletions
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,27 @@ |
|||||||
|
#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("${ProjectName}")] |
||||||
|
[assembly: AssemblyDescription("")] |
||||||
|
[assembly: AssemblyConfiguration("")] |
||||||
|
[assembly: AssemblyCompany("")] |
||||||
|
[assembly: AssemblyProduct("${ProjectName}")] |
||||||
|
[assembly: AssemblyCopyright("Copyright ${DATE:yyyy}")] |
||||||
|
[assembly: AssemblyTrademark("")] |
||||||
|
[assembly: AssemblyCulture("")] |
||||||
|
|
||||||
|
// 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 +1,58 @@ |
|||||||
|
<?xml version="1.0"?> |
||||||
|
<Template originator = "Daniel Grunwald" created = "05/17/2012"> |
||||||
|
|
||||||
|
<!-- Template Header --> |
||||||
|
<TemplateConfiguration> |
||||||
|
<Name>${res:Templates.Project.PortableLibrary.Name}</Name> |
||||||
|
<Category>C#</Category> |
||||||
|
<Icon>C#.Project.Library</Icon> |
||||||
|
<Description>${res:Templates.Project.PortableLibrary.Description}</Description> |
||||||
|
</TemplateConfiguration> |
||||||
|
|
||||||
|
<!-- Actions --> |
||||||
|
<Actions> |
||||||
|
<Open filename = "MyClass.cs"/> |
||||||
|
</Actions> |
||||||
|
|
||||||
|
<!-- Template Content --> |
||||||
|
<Project language="C#"> |
||||||
|
<PreCreateActions> |
||||||
|
<RunCommand path="/SharpDevelop/BackendBindings/TemplateCommands/CheckPortableLibraryInstalled"/> |
||||||
|
</PreCreateActions> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||||
|
<TargetFrameworkProfile>Profile1</TargetFrameworkProfile> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<PropertyGroup escapeValue="False"> |
||||||
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ProjectItems /> |
||||||
|
|
||||||
|
<Imports clear="True"> |
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> |
||||||
|
</Imports> |
||||||
|
|
||||||
|
<Files> |
||||||
|
<File name="MyClass.cs"><![CDATA[${StandardHeader.C#} |
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ${StandardNamespace} |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Description of MyClass. |
||||||
|
/// </summary> |
||||||
|
public class MyClass |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
}]]></File> |
||||||
|
<File name="Properties\AssemblyInfo.cs" src="PortableAssemblyInfo.cs"/> |
||||||
|
</Files> |
||||||
|
</Project> |
||||||
|
</Template> |
@ -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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
#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 @@ |
|||||||
|
|
||||||
|
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 @@ |
|||||||
|
<?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 @@ |
|||||||
|
<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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
<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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
// 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 @@ |
|||||||
|
#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 @@ |
|||||||
//// 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();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -0,0 +1,108 @@ |
|||||||
|
// 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.ComponentModel; |
||||||
|
using System.Drawing; |
||||||
|
using System.IO; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
using ICSharpCode.PythonBinding; |
||||||
|
using ICSharpCode.Scripting.Tests.Utils; |
||||||
|
using NUnit.Framework; |
||||||
|
using PythonBinding.Tests.Utils; |
||||||
|
|
||||||
|
namespace PythonBinding.Tests.Designer |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Fix ArgumentNullException when form has a button followed by a timer and the
|
||||||
|
/// first timer statement is the setting of the event handler.
|
||||||
|
/// </summary>
|
||||||
|
[TestFixture] |
||||||
|
public class LoadFormWithButtonFollowedByTimerTestFixture : LoadFormTestFixtureBase |
||||||
|
{ |
||||||
|
MockPropertyDescriptor mockTickPropertyDescriptor; |
||||||
|
|
||||||
|
public override string PythonCode { |
||||||
|
get { |
||||||
|
return |
||||||
|
"import System.Drawing\r\n" + |
||||||
|
"import System.Windows.Forms\r\n" + |
||||||
|
"\r\n" + |
||||||
|
"from System.Drawing import *\r\n" + |
||||||
|
"from System.Windows.Forms import *\r\n" + |
||||||
|
"\r\n" + |
||||||
|
"class MainForm(Form):\r\n" + |
||||||
|
" def __init__(self):\r\n" + |
||||||
|
" self.InitializeComponent()\r\n" + |
||||||
|
"\r\n" + |
||||||
|
" def InitializeComponent(self):\r\n" + |
||||||
|
" self._components = System.ComponentModel.Container()\r\n" + |
||||||
|
" self._button1 = System.Windows.Forms.Button()\r\n" + |
||||||
|
" self._timer1 = System.Windows.Forms.Timer(self._components)\r\n" + |
||||||
|
" self.SuspendLayout()\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" # button1\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" self._button1.Location = System.Drawing.Point(37, 29)\r\n" + |
||||||
|
" self._button1.Name = \"button1\"\r\n" + |
||||||
|
" self._button1.Size = System.Drawing.Size(75, 23)\r\n" + |
||||||
|
" self._button1.TabIndex = 0\r\n" + |
||||||
|
" self._button1.Text = \"button1\"\r\n" + |
||||||
|
" self._button1.UseVisualStyleBackColor = True\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" # timer1\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" self._timer1.Tick += self.Timer1Tick\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" # MainForm\r\n" + |
||||||
|
" # \r\n" + |
||||||
|
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" + |
||||||
|
" self.Controls.Add(self._button1)\r\n" + |
||||||
|
" self.Name = \"MainForm\"\r\n" + |
||||||
|
" self.Text = \"PyWinTest\"\r\n" + |
||||||
|
" self.ResumeLayout(False)\r\n" + |
||||||
|
"\r\n" + |
||||||
|
"\r\n" + |
||||||
|
" def Timer1Tick(self, sender, e):\r\n" + |
||||||
|
" pass"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override void BeforeSetUpFixture() |
||||||
|
{ |
||||||
|
mockTickPropertyDescriptor = new MockPropertyDescriptor("Tick", null, false); |
||||||
|
ComponentCreator.SetEventPropertyDescriptor(mockTickPropertyDescriptor); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void EventDescriptorUsedToGetEventProperty() |
||||||
|
{ |
||||||
|
Assert.IsNotNull(ComponentCreator.EventDescriptorPassedToGetEventProperty); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void EventDescriptorNameUsedToGetEventPropertyIsTick() |
||||||
|
{ |
||||||
|
Assert.AreEqual("Tick", ComponentCreator.EventDescriptorPassedToGetEventProperty.Name); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetPropertyValueSetForTimer() |
||||||
|
{ |
||||||
|
string value = mockTickPropertyDescriptor.GetValue(null) as String; |
||||||
|
Assert.AreEqual("Timer1Tick", value); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void GetComponentUsedWhenSettingTickHandler() |
||||||
|
{ |
||||||
|
IComponent expectedComponent = ComponentCreator.GetComponent("timer1"); |
||||||
|
|
||||||
|
object component = mockTickPropertyDescriptor.GetSetValueComponent(); |
||||||
|
|
||||||
|
Assert.AreEqual(expectedComponent, component); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue