Skip to content

Commit

Permalink
Merge remote branch 'origin/Silverlight'
Browse files Browse the repository at this point in the history
Conflicts:
	Generator/Configuration/GeneratorConfiguration.cs
	Generator/TechTalk.SpecFlow.Generator.csproj
	Runtime/Configuration/RuntimeConfiguration.cs
  • Loading branch information
gasparnagy committed Jun 29, 2010
2 parents ba58a64 + 3b64673 commit 1c2b235
Show file tree
Hide file tree
Showing 46 changed files with 1,410 additions and 187 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ obj/
_ReSharper*/
[Tt]est[Rr]esult*
*.resharper
*.cache
*.cache
*.gpState
3 changes: 3 additions & 0 deletions Generator/Configuration/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ private void SetUnitTestDefaultsByName(string name)
case "mstest.2010":
GeneratorUnitTestProviderType = typeof(MsTest2010GeneratorProvider);
break;
case "mstest.silverlight":
GeneratorUnitTestProviderType = typeof(MsTestSilverlightGeneratorProvider);
break;
default:
GeneratorUnitTestProviderType = null;
break;
Expand Down
10 changes: 10 additions & 0 deletions Generator/TechTalk.SpecFlow.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Runtime\Configuration\ConfigDefaults.cs">
<Link>Configuration\ConfigDefaults.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationSectionHandler.cs">
<Link>Configuration\ConfigurationSectionHandler.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationServices.cs">
<Link>Configuration\ConfigurationServices.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\MissingOrPendingStepsOutcome.cs">
<Link>Configuration\MissingOrPendingStepsOutcome.cs</Link>
</Compile>
<Compile Include="..\Runtime\StringExtensions.cs">
<Link>StringExtensions.cs</Link>
</Compile>
Expand All @@ -68,6 +77,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpecFlowGenerator.cs" />
<Compile Include="SpecFlowUnitTestConverter.cs" />
<Compile Include="UnitTestProvider\MsTestSilverlightGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\MbUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\MsTest2010GeneratorProvider.cs" />
<Compile Include="UnitTestProvider\XUnitTestGeneratorProvider.cs" />
Expand Down
124 changes: 124 additions & 0 deletions Generator/UnitTestProvider/MsTestSilverlightGeneratorProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System.CodeDom;
using System.Collections.Generic;

namespace TechTalk.SpecFlow.Generator.UnitTestProvider
{
// TODO: it's an ugly copy-paste of MsTestGeneratorProvider - we should consider refactoring the generator creation to support custom factories.
public class MsTestSilverlightGeneratorProvider : IUnitTestGeneratorProvider
{
private const string TESTFIXTURE_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
private const string TEST_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";
private const string PROPERTY_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute";
private const string TESTFIXTURESETUP_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute";
private const string TESTFIXTURETEARDOWN_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute";
private const string TESTSETUP_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute";
private const string TESTTEARDOWN_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute";
private const string IGNORE_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.IgnoreAttribute";
private const string DESCRIPTION_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute";

private const string FEATURE_TITILE_PROPERTY_NAME = "FeatureTitle";
private const string FEATURE_TITILE_KEY = "FeatureTitle";

private const string TESTCONTEXT_TYPE = "Microsoft.VisualStudio.TestTools.UnitTesting.TestContext";

private CodeTypeDeclaration currentTestTypeDeclaration = null;

public void SetTestFixture(CodeTypeDeclaration typeDeclaration, string title, string description)
{
typeDeclaration.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURE_ATTR)));

//as in mstest, you cannot mark classes with the description attribute, we
//just remember the feature title, and we will apply it for each test method
typeDeclaration.UserData[FEATURE_TITILE_KEY] = title;

currentTestTypeDeclaration = typeDeclaration;
}

private void SetDescription(CodeAttributeDeclarationCollection customAttributes, string description)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(DESCRIPTION_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(description))));
}

private void SetProperty(CodeAttributeDeclarationCollection customAttributes, string name, string value)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(PROPERTY_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(name)),
new CodeAttributeArgument(
new CodePrimitiveExpression(value))));
}

public void SetTestFixtureCategories(CodeTypeDeclaration typeDeclaration, IEnumerable<string> categories)
{
//MsTest does not support caregories... :(
}

public void SetTest(CodeMemberMethod memberMethod, string title)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TEST_ATTR)));

SetDescription(memberMethod.CustomAttributes, title);

if (currentTestTypeDeclaration == null)
return;

string featureTitle = currentTestTypeDeclaration.UserData[FEATURE_TITILE_KEY] as string;
if (featureTitle != null)
SetProperty(memberMethod.CustomAttributes, FEATURE_TITILE_PROPERTY_NAME, featureTitle);
}

public void SetTestCategories(CodeMemberMethod memberMethod, IEnumerable<string> categories)
{
//MsTest does not support caregories... :(
}

public void SetTestSetup(CodeMemberMethod memberMethod)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTSETUP_ATTR)));
}

public void SetTestFixtureSetup(CodeMemberMethod memberMethod)
{
memberMethod.Attributes |= MemberAttributes.Static;

memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURESETUP_ATTR)));
}

public void SetTestFixtureTearDown(CodeMemberMethod memberMethod)
{
memberMethod.Attributes |= MemberAttributes.Static;

memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURETEARDOWN_ATTR)));
}

public void SetTestTearDown(CodeMemberMethod memberMethod)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTTEARDOWN_ATTR)));
}

public void SetIgnore(CodeTypeMember codeTypeMember)
{
codeTypeMember.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(IGNORE_ATTR)));
}
}
}
1 change: 1 addition & 0 deletions Installer/SpecFlowInstaller/Common.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<?define CLSID_SpecFlowSingleFileGenerator = "{3c9cf10a-a9ab-4899-a0fb-4b3be4a36c15}" ?>
<?define VBLangId = "{164B10B9-B200-11D0-8C61-00A0C91E29D5}" ?>
<?define CSharpLangId = "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}" ?>
<?define SilverlightPackageId = "{CB22EE0E-4072-4ae7-96E2-90FCCF879544}" ?>

</Include>
27 changes: 15 additions & 12 deletions Installer/SpecFlowInstaller/Product.Generated.wxs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="Product.Generated">
<ComponentGroupRef Id="TechTalk.SpecFlow.Generator.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Parser.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Reporting.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Tools.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.VsIntegration.Binaries" />
</ComponentGroup>
</Fragment>
<?xml version='1.0' encoding='UTF-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="Product.Generated">
<ComponentGroupRef Id="TechTalk.SpecFlow.Generator.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Parser.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Reporting.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Content" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Satellites" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Tools.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.VsIntegration.Binaries" />
</ComponentGroup>
</Fragment>
</Wix>
Loading

0 comments on commit 1c2b235

Please sign in to comment.