diff --git a/Generator/Configuration/GeneratorConfiguration.cs b/Generator/Configuration/GeneratorConfiguration.cs
index 93da8e37e..9ff0be821 100644
--- a/Generator/Configuration/GeneratorConfiguration.cs
+++ b/Generator/Configuration/GeneratorConfiguration.cs
@@ -69,6 +69,9 @@ private void SetUnitTestDefaultsByName(string name)
case "nunit":
GeneratorUnitTestProviderType = typeof(NUnitTestConverter);
break;
+ case "mbunit":
+ GeneratorUnitTestProviderType = typeof(MbUnitTestGeneratorProvider);
+ break;
case "xunit":
GeneratorUnitTestProviderType = typeof(XUnitTestGeneratorProvider);
break;
diff --git a/Generator/TechTalk.SpecFlow.Generator.csproj b/Generator/TechTalk.SpecFlow.Generator.csproj
index 77d3c3544..9e91a1bdd 100644
--- a/Generator/TechTalk.SpecFlow.Generator.csproj
+++ b/Generator/TechTalk.SpecFlow.Generator.csproj
@@ -68,6 +68,7 @@
+
diff --git a/Generator/UnitTestProvider/MbUnitTestGeneratorProvider.cs b/Generator/UnitTestProvider/MbUnitTestGeneratorProvider.cs
new file mode 100644
index 000000000..3d91442db
--- /dev/null
+++ b/Generator/UnitTestProvider/MbUnitTestGeneratorProvider.cs
@@ -0,0 +1,104 @@
+using System;
+using System.CodeDom;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace TechTalk.SpecFlow.Generator.UnitTestProvider
+{
+ public class MbUnitTestGeneratorProvider : IUnitTestGeneratorProvider
+ {
+ private const string TESTFIXTURE_ATTR = "MbUnit.Framework.TestFixtureAttribute";
+ private const string TEST_ATTR = "MbUnit.Framework.TestAttribute";
+ private const string CATEGORY_ATTR = "MbUnit.Framework.CategoryAttribute";
+ private const string TESTSETUP_ATTR = "MbUnit.Framework.SetUpAttribute";
+ private const string TESTFIXTURESETUP_ATTR = "MbUnit.Framework.FixtureSetUpAttribute";
+ private const string TESTFIXTURETEARDOWN_ATTR = "MbUnit.Framework.FixtureTearDownAttribute";
+ private const string TESTTEARDOWN_ATTR = "MbUnit.Framework.TearDownAttribute";
+ private const string IGNORE_ATTR = "MbUnit.Framework.IgnoreAttribute";
+ private const string DESCRIPTION_ATTR = "MbUnit.Framework.DescriptionAttribute";
+
+ public void SetTestFixture(CodeTypeDeclaration typeDeclaration, string title, string description)
+ {
+ typeDeclaration.CustomAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(TESTFIXTURE_ATTR)));
+
+ SetDescription(typeDeclaration.CustomAttributes, title);
+ }
+
+ private void SetDescription(CodeAttributeDeclarationCollection customAttributes, string description)
+ {
+ customAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(DESCRIPTION_ATTR),
+ new CodeAttributeArgument(
+ new CodePrimitiveExpression(description))));
+ }
+
+ private void SetCategories(CodeAttributeDeclarationCollection customAttributes, IEnumerable categories)
+ {
+ foreach (var category in categories)
+ {
+ customAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(CATEGORY_ATTR),
+ new CodeAttributeArgument(
+ new CodePrimitiveExpression(category))));
+ }
+ }
+
+ public void SetTestFixtureCategories(CodeTypeDeclaration typeDeclaration, IEnumerable categories)
+ {
+ SetCategories(typeDeclaration.CustomAttributes, categories);
+ }
+
+ public void SetTest(CodeMemberMethod memberMethod, string title)
+ {
+ memberMethod.CustomAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(TEST_ATTR)));
+
+ SetDescription(memberMethod.CustomAttributes, title);
+ }
+
+ public void SetTestCategories(CodeMemberMethod memberMethod, IEnumerable categories)
+ {
+ SetCategories(memberMethod.CustomAttributes, categories);
+ }
+
+ public void SetTestSetup(CodeMemberMethod memberMethod)
+ {
+ memberMethod.CustomAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(TESTSETUP_ATTR)));
+ }
+
+ public void SetTestFixtureSetup(CodeMemberMethod memberMethod)
+ {
+ memberMethod.CustomAttributes.Add(
+ new CodeAttributeDeclaration(
+ new CodeTypeReference(TESTFIXTURESETUP_ATTR)));
+ }
+
+ public void SetTestFixtureTearDown(CodeMemberMethod memberMethod)
+ {
+ 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)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Configuration/RuntimeConfiguration.cs b/Runtime/Configuration/RuntimeConfiguration.cs
index 92d95eddb..a82f3b70e 100644
--- a/Runtime/Configuration/RuntimeConfiguration.cs
+++ b/Runtime/Configuration/RuntimeConfiguration.cs
@@ -146,6 +146,9 @@ private void SetUnitTestDefaultsByName(string name)
case "nunit":
RuntimeUnitTestProviderType = typeof(NUnitRuntimeProvider);
break;
+ case "mbunit":
+ RuntimeUnitTestProviderType = typeof(MbUnitRuntimeProvider);
+ break;
case "xunit":
RuntimeUnitTestProviderType = typeof(XUnitRuntimeProvider);
break;
diff --git a/Runtime/TechTalk.SpecFlow.csproj b/Runtime/TechTalk.SpecFlow.csproj
index 4e6e51e8a..697d17ac9 100644
--- a/Runtime/TechTalk.SpecFlow.csproj
+++ b/Runtime/TechTalk.SpecFlow.csproj
@@ -80,6 +80,7 @@
+
diff --git a/Runtime/UnitTestProvider/MbUnitRuntimeProvider.cs b/Runtime/UnitTestProvider/MbUnitRuntimeProvider.cs
new file mode 100644
index 000000000..022422576
--- /dev/null
+++ b/Runtime/UnitTestProvider/MbUnitRuntimeProvider.cs
@@ -0,0 +1,37 @@
+using System;
+
+namespace TechTalk.SpecFlow.UnitTestProvider
+{
+ public class MbUnitRuntimeProvider : IUnitTestRuntimeProvider
+ {
+ private const string MSTEST_ASSEMBLY = "MbUnit";
+ private const string ASSERT_TYPE = "MbUnit.Framework.Assert";
+
+ private Action assertInconclusive;
+
+ #region IUnitTestRuntimeProvider Members
+
+ public void TestInconclusive(string message)
+ {
+ if (assertInconclusive == null)
+ {
+ assertInconclusive = UnitTestRuntimeProviderHelper
+ .GetAssertMethod(MSTEST_ASSEMBLY, ASSERT_TYPE, "Inconclusive");
+ }
+
+ assertInconclusive(message);
+ }
+
+ public void TestIgnore(string message)
+ {
+ TestInconclusive(message); // there is no dynamic "Ignore" in mstest
+ }
+
+ public bool DelayedFixtureTearDown
+ {
+ get { return true; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Tests/ParserTests/ParserTests.csproj b/Tests/ParserTests/ParserTests.csproj
index 357bb12d6..cbc09a210 100644
--- a/Tests/ParserTests/ParserTests.csproj
+++ b/Tests/ParserTests/ParserTests.csproj
@@ -33,6 +33,10 @@
4
+
+ False
+ ..\..\lib\mbunit\MbUnit.dll
+
False
..\..\lib\nunit\nunit.framework.dll
@@ -51,11 +55,14 @@
+
+
+
diff --git a/Tests/ParserTests/SuccessfulGenerationTest.cs b/Tests/ParserTests/SuccessfulGenerationTest.cs
index fe82050e7..fa0566f3f 100644
--- a/Tests/ParserTests/SuccessfulGenerationTest.cs
+++ b/Tests/ParserTests/SuccessfulGenerationTest.cs
@@ -1,12 +1,9 @@
using System;
+using System.CodeDom;
using System.CodeDom.Compiler;
-using System.Collections.Generic;
using System.Globalization;
using System.IO;
-using System.Linq;
-using System.Reflection;
using System.Text;
-using System.Xml.Serialization;
using Microsoft.CSharp;
using NUnit.Framework;
using TechTalk.SpecFlow.Generator;
@@ -19,167 +16,167 @@ namespace ParserTests
[TestFixture]
public class SuccessfulGenerationTest
{
- [Test]
- public void CanGenerateFromFiles()
+ private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
+ {
+ string expected = TestFileHelper.ReadFile(expectedResultFileName);
+ string got = GenerateCodeFromFeature(feature);
+
+ Assert.AreEqual(expected, got);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
+ {
+ var converter = new SpecFlowUnitTestConverter(new NUnitTestConverter(),
+ new CodeDomHelper(GenerationTargetLanguage.CSharp), true);
+ CodeNamespace codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");
+
+ var codeProvider = new CSharpCodeProvider();
+ var options = new CodeGeneratorOptions();
+ codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, string fileName)
{
- foreach (var testFile in TestFileHelper.GetTestFiles())
+ using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
- CanGenerateFromFile(testFile);
+ GenerateCodeFromFeature(feature, writer);
+ }
+ }
+
+ private string GenerateCodeFromFeature(Feature feature)
+ {
+ using (var writer = new Utf8StringWriter())
+ {
+ GenerateCodeFromFeature(feature, writer);
+ return writer.ToString();
}
}
[Test]
- public void CanGenerateSimpleFeature()
+ public void CanGenerateButFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "but.feature"));
}
[Test]
public void CanGenerateCommentsFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "comments.feature"));
}
[Test]
public void CanGenerateFeatureheaderFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "featureheader.feature"));
}
- [Test]
- public void CanGenerateTagsFeature()
+ [Test, TestCaseSource(typeof (TestFileHelper), "GetTestFiles")]
+ public void CanGenerateFromFile(string fileName)
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
- }
+ Console.WriteLine(fileName);
+ var parser = new SpecFlowLangParser(new CultureInfo("en-US"));
+ using (var reader = new StreamReader(fileName))
+ {
+ Feature feature = parser.Parse(reader);
+ Assert.IsNotNull(feature);
- [Test]
- public void CanGeneratebackgroundFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "background.feature"));
- }
+ string generatedCode = GenerateCodeFromFeature(feature);
+ Assert.IsNotNull(generatedCode);
- [Test]
- public void CanGeneratebackgroundWithTitleFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
+ // to regenerate the expected result file:
+ //GenerateCodeFromFeature(feature, fileName + ".cs");
+
+ //CompareWithExpectedResult(feature, fileName + ".cs");
+ }
}
[Test]
- public void CanGenerateWhitespacesFeature()
+ public void CanGenerateFromFiles()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
+ foreach (string testFile in TestFileHelper.GetTestFiles())
+ {
+ CanGenerateFromFile(testFile);
+ }
}
[Test]
public void CanGenerateGivenWhenThenDuplicationFeatureFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "givenwhenthenduplication.feature"));
}
[Test]
- public void CanGenerateButFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "but.feature"));
- }
-
- [Test]
- public void CanGenerateMultilinetitleFeature()
+ public void CanGenerateMixedGWTFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
}
[Test]
public void CanGenerateMultilineargumentFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "multilineargument.feature"));
}
[Test]
- public void CanGenerateTableargumentFeature()
+ public void CanGenerateMultilinetitleFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
}
[Test]
public void CanGenerateScneriooutlineFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "scenariooutline.feature"));
}
[Test]
- public void CanGenerateMixedGWTFeature()
+ public void CanGenerateSimpleFeature()
{
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
}
-
- [Test, TestCaseSource(typeof(TestFileHelper), "GetTestFiles")]
- public void CanGenerateFromFile(string fileName)
+ [Test]
+ public void CanGenerateTableargumentFeature()
{
- Console.WriteLine(fileName);
- SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en-US"));
- using (var reader = new StreamReader(fileName))
- {
- Feature feature = parser.Parse(reader);
- Assert.IsNotNull(feature);
-
- string generatedCode = GenerateCodeFromFeature(feature);
- Assert.IsNotNull(generatedCode);
-
- // to regenerate the expected result file:
- //GenerateCodeFromFeature(feature, fileName + ".cs");
-
- //CompareWithExpectedResult(feature, fileName + ".cs");
- }
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
}
- private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
+ [Test]
+ public void CanGenerateTagsFeature()
{
- string expected = TestFileHelper.ReadFile(expectedResultFileName);
- string got = GenerateCodeFromFeature(feature);
-
- Assert.AreEqual(expected, got);
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
}
- private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
+ [Test]
+ public void CanGenerateWhitespacesFeature()
{
- SpecFlowUnitTestConverter converter = new SpecFlowUnitTestConverter(new NUnitTestConverter(), new CodeDomHelper(GenerationTargetLanguage.CSharp), true);
- var codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");
-
- CSharpCodeProvider codeProvider = new CSharpCodeProvider();
- CodeGeneratorOptions options = new CodeGeneratorOptions();
- codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
}
- private void GenerateCodeFromFeature(Feature feature, string fileName)
+ [Test]
+ public void CanGeneratebackgroundFeature()
{
- using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
- {
- GenerateCodeFromFeature(feature, writer);
- }
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background.feature"));
}
- private string GenerateCodeFromFeature(Feature feature)
+ [Test]
+ public void CanGeneratebackgroundWithTitleFeature()
{
- using (var writer = new Utf8StringWriter())
- {
- GenerateCodeFromFeature(feature, writer);
- return writer.ToString();
- }
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
}
}
-}
+}
\ No newline at end of file
diff --git a/Tests/ParserTests/SuccessfulMbUnitGenerationTest.cs b/Tests/ParserTests/SuccessfulMbUnitGenerationTest.cs
new file mode 100644
index 000000000..ec2a39577
--- /dev/null
+++ b/Tests/ParserTests/SuccessfulMbUnitGenerationTest.cs
@@ -0,0 +1,183 @@
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using Microsoft.CSharp;
+using NUnit.Framework;
+using TechTalk.SpecFlow.Generator;
+using TechTalk.SpecFlow.Generator.UnitTestProvider;
+using TechTalk.SpecFlow.Parser;
+using TechTalk.SpecFlow.Parser.SyntaxElements;
+
+namespace ParserTests
+{
+ [TestFixture]
+ public class SuccessfulMbUnitGenerationTest
+ {
+ private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
+ {
+ string expected = TestFileHelper.ReadFile(expectedResultFileName);
+ string got = GenerateCodeFromFeature(feature);
+
+ Assert.AreEqual(expected, got);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
+ {
+ var codeDomHelper = new CodeDomHelper(GenerationTargetLanguage.CSharp);
+ var mbUnitTestGeneratorProvider = new MbUnitTestGeneratorProvider();
+ var converter = new SpecFlowUnitTestConverter(mbUnitTestGeneratorProvider, codeDomHelper, true);
+ CodeNamespace codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");
+
+ var codeProvider = new CSharpCodeProvider();
+ var options = new CodeGeneratorOptions();
+ codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, string fileName)
+ {
+ using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
+ {
+ GenerateCodeFromFeature(feature, writer);
+ }
+ }
+
+ private string GenerateCodeFromFeature(Feature feature)
+ {
+ using (var writer = new Utf8StringWriter())
+ {
+ GenerateCodeFromFeature(feature, writer);
+ return writer.ToString();
+ }
+ }
+
+ [Test]
+ public void CanGenerateButFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "but.feature"));
+ }
+
+ [Test]
+ public void CanGenerateCommentsFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "comments.feature"));
+ }
+
+ [Test]
+ public void CanGenerateFeatureheaderFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "featureheader.feature"));
+ }
+
+ [Test, TestCaseSource(typeof (TestFileHelper), "GetTestFiles")]
+ public void CanGenerateFromFile(string fileName)
+ {
+ Console.WriteLine(fileName);
+ var parser = new SpecFlowLangParser(new CultureInfo("en-US"));
+ using (var reader = new StreamReader(fileName))
+ {
+ Feature feature = parser.Parse(reader);
+ Assert.IsNotNull(feature);
+
+ string generatedCode = GenerateCodeFromFeature(feature);
+ Assert.IsNotNull(generatedCode);
+
+ // to regenerate the expected result file:
+ //GenerateCodeFromFeature(feature, fileName + ".cs");
+
+ //CompareWithExpectedResult(feature, fileName + ".cs");
+ }
+ }
+
+ [Test]
+ public void CanGenerateFromFiles()
+ {
+ foreach (string testFile in TestFileHelper.GetTestFiles())
+ {
+ CanGenerateFromFile(testFile);
+ }
+ }
+
+ [Test]
+ public void CanGenerateGivenWhenThenDuplicationFeatureFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "givenwhenthenduplication.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMixedGWTFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMultilineargumentFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "multilineargument.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMultilinetitleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
+ }
+
+ [Test]
+ public void CanGenerateScneriooutlineFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "scenariooutline.feature"));
+ }
+
+ [Test]
+ public void CanGenerateSimpleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
+ }
+
+ [Test]
+ public void CanGenerateTableargumentFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
+ }
+
+ [Test]
+ public void CanGenerateTagsFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
+ }
+
+ [Test]
+ public void CanGenerateWhitespacesFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
+ }
+
+ [Test]
+ public void CanGeneratebackgroundFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background.feature"));
+ }
+
+ [Test]
+ public void CanGeneratebackgroundWithTitleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tests/ParserTests/SuccessfulXUnitGenerationTest.cs b/Tests/ParserTests/SuccessfulXUnitGenerationTest.cs
index e3f313b97..a2bc395d6 100644
--- a/Tests/ParserTests/SuccessfulXUnitGenerationTest.cs
+++ b/Tests/ParserTests/SuccessfulXUnitGenerationTest.cs
@@ -1,12 +1,9 @@
using System;
+using System.CodeDom;
using System.CodeDom.Compiler;
-using System.Collections.Generic;
using System.Globalization;
using System.IO;
-using System.Linq;
-using System.Reflection;
using System.Text;
-using System.Xml.Serialization;
using Microsoft.CSharp;
using NUnit.Framework;
using TechTalk.SpecFlow.Generator;
@@ -16,172 +13,171 @@
namespace ParserTests
{
- [TestFixture]
- public class SuccessfulXUnitGenerationTest
- {
- [Test]
- public void CanGenerateFromFiles()
- {
- foreach (var testFile in TestFileHelper.GetTestFiles())
- {
- CanGenerateFromFile(testFile);
- }
- }
-
- [Test]
- public void CanGenerateSimpleFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
- }
-
- [Test]
- public void CanGenerateCommentsFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "comments.feature"));
- }
-
- [Test]
- public void CanGenerateFeatureheaderFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "featureheader.feature"));
- }
-
- [Test]
- public void CanGenerateTagsFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
- }
-
- [Test]
- public void CanGeneratebackgroundFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "background.feature"));
- }
-
- [Test]
- public void CanGeneratebackgroundWithTitleFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
- }
-
- [Test]
- public void CanGenerateWhitespacesFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
- }
-
- [Test]
- public void CanGenerateGivenWhenThenDuplicationFeatureFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "givenwhenthenduplication.feature"));
- }
-
- [Test]
- public void CanGenerateButFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "but.feature"));
- }
-
- [Test]
- public void CanGenerateMultilinetitleFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
- }
-
- [Test]
- public void CanGenerateMultilineargumentFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "multilineargument.feature"));
- }
-
- [Test]
- public void CanGenerateTableargumentFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
- }
-
- [Test]
- public void CanGenerateScneriooutlineFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "scenariooutline.feature"));
- }
-
- [Test]
- public void CanGenerateMixedGWTFeature()
- {
- var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
- CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
- }
-
-
- [Test, TestCaseSource(typeof(TestFileHelper), "GetTestFiles")]
- public void CanGenerateFromFile(string fileName)
- {
- Console.WriteLine(fileName);
- SpecFlowLangParser parser = new SpecFlowLangParser(new CultureInfo("en-US"));
- using (var reader = new StreamReader(fileName))
- {
- Feature feature = parser.Parse(reader);
- Assert.IsNotNull(feature);
-
- string generatedCode = GenerateCodeFromFeature(feature);
- Assert.IsNotNull(generatedCode);
-
- // to regenerate the expected result file:
- //GenerateCodeFromFeature(feature, fileName + ".cs");
-
- //CompareWithExpectedResult(feature, fileName + ".cs");
- }
- }
-
- private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
- {
- string expected = TestFileHelper.ReadFile(expectedResultFileName);
- string got = GenerateCodeFromFeature(feature);
-
- Assert.AreEqual(expected, got);
- }
-
- private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
- {
- CodeDomHelper codeDomHelper = new CodeDomHelper(GenerationTargetLanguage.CSharp);
- XUnitTestGeneratorProvider xUnitTestGeneratorProvider = new XUnitTestGeneratorProvider();
- SpecFlowUnitTestConverter converter = new SpecFlowUnitTestConverter(xUnitTestGeneratorProvider, codeDomHelper, true);
- var codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");
-
- CSharpCodeProvider codeProvider = new CSharpCodeProvider();
- CodeGeneratorOptions options = new CodeGeneratorOptions();
- codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
- }
-
- private void GenerateCodeFromFeature(Feature feature, string fileName)
- {
- using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
- {
- GenerateCodeFromFeature(feature, writer);
- }
- }
-
- private string GenerateCodeFromFeature(Feature feature)
- {
- using (var writer = new Utf8StringWriter())
- {
- GenerateCodeFromFeature(feature, writer);
- return writer.ToString();
- }
- }
- }
-}
+ [TestFixture]
+ public class SuccessfulXUnitGenerationTest
+ {
+ private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
+ {
+ string expected = TestFileHelper.ReadFile(expectedResultFileName);
+ string got = GenerateCodeFromFeature(feature);
+
+ Assert.AreEqual(expected, got);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
+ {
+ var codeDomHelper = new CodeDomHelper(GenerationTargetLanguage.CSharp);
+ var xUnitTestGeneratorProvider = new XUnitTestGeneratorProvider();
+ var converter = new SpecFlowUnitTestConverter(xUnitTestGeneratorProvider, codeDomHelper, true);
+ CodeNamespace codeNamespace = converter.GenerateUnitTestFixture(feature, "TestClassName", "Target.Namespace");
+
+ var codeProvider = new CSharpCodeProvider();
+ var options = new CodeGeneratorOptions();
+ codeProvider.GenerateCodeFromNamespace(codeNamespace, writer, options);
+ }
+
+ private void GenerateCodeFromFeature(Feature feature, string fileName)
+ {
+ using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
+ {
+ GenerateCodeFromFeature(feature, writer);
+ }
+ }
+
+ private string GenerateCodeFromFeature(Feature feature)
+ {
+ using (var writer = new Utf8StringWriter())
+ {
+ GenerateCodeFromFeature(feature, writer);
+ return writer.ToString();
+ }
+ }
+
+ [Test]
+ public void CanGenerateButFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "but.feature"));
+ }
+
+ [Test]
+ public void CanGenerateCommentsFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "comments.feature"));
+ }
+
+ [Test]
+ public void CanGenerateFeatureheaderFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "featureheader.feature"));
+ }
+
+ [Test, TestCaseSource(typeof (TestFileHelper), "GetTestFiles")]
+ public void CanGenerateFromFile(string fileName)
+ {
+ Console.WriteLine(fileName);
+ var parser = new SpecFlowLangParser(new CultureInfo("en-US"));
+ using (var reader = new StreamReader(fileName))
+ {
+ Feature feature = parser.Parse(reader);
+ Assert.IsNotNull(feature);
+
+ string generatedCode = GenerateCodeFromFeature(feature);
+ Assert.IsNotNull(generatedCode);
+
+ // to regenerate the expected result file:
+ //GenerateCodeFromFeature(feature, fileName + ".cs");
+
+ //CompareWithExpectedResult(feature, fileName + ".cs");
+ }
+ }
+
+ [Test]
+ public void CanGenerateFromFiles()
+ {
+ foreach (string testFile in TestFileHelper.GetTestFiles())
+ {
+ CanGenerateFromFile(testFile);
+ }
+ }
+
+ [Test]
+ public void CanGenerateGivenWhenThenDuplicationFeatureFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "givenwhenthenduplication.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMixedGWTFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMultilineargumentFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "multilineargument.feature"));
+ }
+
+ [Test]
+ public void CanGenerateMultilinetitleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
+ }
+
+ [Test]
+ public void CanGenerateScneriooutlineFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "scenariooutline.feature"));
+ }
+
+ [Test]
+ public void CanGenerateSimpleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
+ }
+
+ [Test]
+ public void CanGenerateTableargumentFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
+ }
+
+ [Test]
+ public void CanGenerateTagsFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
+ }
+
+ [Test]
+ public void CanGenerateWhitespacesFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
+ }
+
+ [Test]
+ public void CanGeneratebackgroundFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background.feature"));
+ }
+
+ [Test]
+ public void CanGeneratebackgroundWithTitleFeature()
+ {
+ string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
+ CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tests/ParserTests/TestFrameworks/MbUnitTestActivator.cs b/Tests/ParserTests/TestFrameworks/MbUnitTestActivator.cs
new file mode 100644
index 000000000..1317b2044
--- /dev/null
+++ b/Tests/ParserTests/TestFrameworks/MbUnitTestActivator.cs
@@ -0,0 +1,38 @@
+using System;
+using NUnit.Framework;
+
+namespace ParserTests.TestFrameworks
+{
+ [TestFixture]
+ public class MbUnitTestActivator
+ {
+ private const string TESTFIXTURE_ATTR = "MbUnit.Framework.TestFixtureAttribute";
+ private const string TEST_ATTR = "MbUnit.Framework.TestAttribute";
+ private const string CATEGORY_ATTR = "MbUnit.Framework.CategoryAttribute";
+ private const string TESTSETUP_ATTR = "MbUnit.Framework.SetUpAttribute";
+ private const string TESTFIXTURESETUP_ATTR = "MbUnit.Framework.FixtureSetUpAttribute";
+ private const string TESTFIXTURETEARDOWN_ATTR = "MbUnit.Framework.FixtureTearDownAttribute";
+ private const string TESTTEARDOWN_ATTR = "MbUnit.Framework.TearDownAttribute";
+ private const string IGNORE_ATTR = "MbUnit.Framework.IgnoreAttribute";
+ private const string DESCRIPTION_ATTR = "MbUnit.Framework.DescriptionAttribute";
+
+ private const string MSTEST_ASSEMBLY = "MbUnit";
+ private const string ASSERT_TYPE = "MbUnit.Framework.Assert";
+
+ [Test]
+ public void CanGenerateButFeature()
+ {
+ Assert.IsNotNull(Type.GetType(TESTFIXTURE_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(TEST_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(CATEGORY_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(TESTSETUP_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(TESTFIXTURESETUP_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(TESTFIXTURETEARDOWN_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(TESTTEARDOWN_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(IGNORE_ATTR + ",MbUnit"));
+ Assert.IsNotNull(Type.GetType(DESCRIPTION_ATTR + ",MbUnit"));
+
+ Assert.IsNotNull(Type.GetType(ASSERT_TYPE + "," + MSTEST_ASSEMBLY));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Tests/ParserTests/TestFrameworks/NUnitTestActivator.cs b/Tests/ParserTests/TestFrameworks/NUnitTestActivator.cs
new file mode 100644
index 000000000..7d3c4001b
--- /dev/null
+++ b/Tests/ParserTests/TestFrameworks/NUnitTestActivator.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using TechTalk.SpecFlow.Generator.UnitTestProvider;
+
+namespace ParserTests.TestFrameworks
+{
+ [TestFixture]
+ public class NUnitTestActivator
+ {
+ private const string TESTFIXTURE_ATTR = "NUnit.Framework.TestFixtureAttribute";
+ private const string TEST_ATTR = "NUnit.Framework.TestAttribute";
+ private const string CATEGORY_ATTR = "NUnit.Framework.CategoryAttribute";
+ private const string TESTSETUP_ATTR = "NUnit.Framework.SetUpAttribute";
+ private const string TESTFIXTURESETUP_ATTR = "NUnit.Framework.TestFixtureSetUpAttribute";
+ private const string TESTFIXTURETEARDOWN_ATTR = "NUnit.Framework.TestFixtureTearDownAttribute";
+ private const string TESTTEARDOWN_ATTR = "NUnit.Framework.TearDownAttribute";
+ private const string IGNORE_ATTR = "NUnit.Framework.IgnoreAttribute";
+ private const string DESCRIPTION_ATTR = "NUnit.Framework.DescriptionAttribute";
+
+ [Test]
+ public void CanGenerateButFeature()
+ {
+ Assert.IsNotNull(Type.GetType(TESTFIXTURE_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(TEST_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(CATEGORY_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(TESTSETUP_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(TESTFIXTURESETUP_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(TESTFIXTURETEARDOWN_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(TESTTEARDOWN_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(IGNORE_ATTR + ",nunit.framework"));
+ Assert.IsNotNull(Type.GetType(DESCRIPTION_ATTR + ",nunit.framework"));
+ }
+ }
+}
diff --git a/Tests/RuntimeTests/ConfigurationTest.cs b/Tests/RuntimeTests/ConfigurationTest.cs
index d8e3e7e38..de6e8caec 100644
--- a/Tests/RuntimeTests/ConfigurationTest.cs
+++ b/Tests/RuntimeTests/ConfigurationTest.cs
@@ -18,9 +18,7 @@ public void CanLoadConfigFromConfigFile()
}
[Test]
- public void CanLoadConfigFromString()
- {
- const string configString = @"
+ [TestCase(@"
-";
+")]
+ public void CanLoadConfigFromString(string configString)
+ {
+ //const string configString = ;
var runtimeConfig = RuntimeConfiguration.LoadFromConfigFile(
ConfigurationSectionHandler.CreateFromXml(configString));
diff --git a/lib/gallio/Gallio.dll b/lib/gallio/Gallio.dll
new file mode 100644
index 000000000..dec207217
Binary files /dev/null and b/lib/gallio/Gallio.dll differ
diff --git a/lib/mbunit/MbUnit.dll b/lib/mbunit/MbUnit.dll
new file mode 100644
index 000000000..ed7df98dd
Binary files /dev/null and b/lib/mbunit/MbUnit.dll differ