Skip to content

Commit

Permalink
* remove references to Gallio and MbUnit
Browse files Browse the repository at this point in the history
* revert 2 generator I had modified by mistake with ReSharper
  • Loading branch information
smnbss committed Jun 3, 2010
1 parent 5e7f6ce commit 593a62e
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 340 deletions.
6 changes: 0 additions & 6 deletions Tests/ParserTests/ParserTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MbUnit, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\mbunit\MbUnit.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.1.9189, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\nunit\nunit.framework.dll</HintPath>
Expand All @@ -61,8 +57,6 @@
<Compile Include="SuccessfulParsingTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestFileHelper.cs" />
<Compile Include="TestFrameworks\MbUnitTestActivator.cs" />
<Compile Include="TestFrameworks\NUnitTestActivator.cs" />
<Compile Include="Utf8StringWriter.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
183 changes: 93 additions & 90 deletions Tests/ParserTests/SuccessfulGenerationTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
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;
Expand All @@ -16,167 +19,167 @@ namespace ParserTests
[TestFixture]
public class SuccessfulGenerationTest
{
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)
{
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
GenerateCodeFromFeature(feature, writer);
}
}

private string GenerateCodeFromFeature(Feature feature)
[Test]
public void CanGenerateFromFiles()
{
using (var writer = new Utf8StringWriter())
foreach (var testFile in TestFileHelper.GetTestFiles())
{
GenerateCodeFromFeature(feature, writer);
return writer.ToString();
CanGenerateFromFile(testFile);
}
}

[Test]
public void CanGenerateButFeature()
public void CanGenerateSimpleFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "but.feature"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
}

[Test]
public void CanGenerateCommentsFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
var 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"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "featureheader.feature"));
}

[Test, TestCaseSource(typeof (TestFileHelper), "GetTestFiles")]
public void CanGenerateFromFile(string fileName)
[Test]
public void CanGenerateTagsFeature()
{
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);
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
}

// to regenerate the expected result file:
//GenerateCodeFromFeature(feature, fileName + ".cs");
[Test]
public void CanGeneratebackgroundFeature()
{
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "background.feature"));
}

//CompareWithExpectedResult(feature, fileName + ".cs");
}
[Test]
public void CanGeneratebackgroundWithTitleFeature()
{
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
}

[Test]
public void CanGenerateFromFiles()
public void CanGenerateWhitespacesFeature()
{
foreach (string testFile in TestFileHelper.GetTestFiles())
{
CanGenerateFromFile(testFile);
}
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
}

[Test]
public void CanGenerateGivenWhenThenDuplicationFeatureFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "givenwhenthenduplication.feature"));
}

[Test]
public void CanGenerateMixedGWTFeature()
public void CanGenerateButFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
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()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "multilineargument.feature"));
}

[Test]
public void CanGenerateMultilinetitleFeature()
public void CanGenerateTableargumentFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "multilinetitle.feature"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
}

[Test]
public void CanGenerateScneriooutlineFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "scenariooutline.feature"));
}

[Test]
public void CanGenerateSimpleFeature()
public void CanGenerateMixedGWTFeature()
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "mixedgivenwhenthen.feature"));
}

[Test]
public void CanGenerateTableargumentFeature()

[Test, TestCaseSource(typeof(TestFileHelper), "GetTestFiles")]
public void CanGenerateFromFile(string fileName)
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "tableargument.feature"));
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");
}
}

[Test]
public void CanGenerateTagsFeature()
private void CompareWithExpectedResult(Feature feature, string expectedResultFileName)
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "tags.feature"));
string expected = TestFileHelper.ReadFile(expectedResultFileName);
string got = GenerateCodeFromFeature(feature);

Assert.AreEqual(expected, got);
}

[Test]
public void CanGenerateWhitespacesFeature()
private void GenerateCodeFromFeature(Feature feature, TextWriter writer)
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "whitespaces.feature"));
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);
}

[Test]
public void CanGeneratebackgroundFeature()
private void GenerateCodeFromFeature(Feature feature, string fileName)
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "background.feature"));
using (var writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
GenerateCodeFromFeature(feature, writer);
}
}

[Test]
public void CanGeneratebackgroundWithTitleFeature()
private string GenerateCodeFromFeature(Feature feature)
{
string folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "background_withtitle.feature"));
using (var writer = new Utf8StringWriter())
{
GenerateCodeFromFeature(feature, writer);
return writer.ToString();
}
}
}
}
}
Loading

0 comments on commit 593a62e

Please sign in to comment.