Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a0d8f39
Split of StepArgumentTypeConverter logic
Sep 10, 2012
b1f4309
Improved StepArgumentTransformation validation
Sep 11, 2012
aff34a3
StepArgumentTypeConverter support spaces in enums
Sep 11, 2012
858f582
StepArgumentTypeConverter support for tables
Sep 11, 2012
d962026
Added test for single header horizontal tables
Sep 12, 2012
2acba81
Changed constructor selection in Table conversion
Sep 12, 2012
014320d
Fixed nullable types issues
Nov 19, 2012
b228142
Revert "Fixed nullable types issues"
Nov 19, 2012
974c5e0
Fixed nullable types issues
Nov 20, 2012
b5e9dc9
Updated changelog to contain nullable enum fix
Nov 20, 2012
5073683
BindingInvoker now waits for any Task that a step returns (and report…
robfe Apr 18, 2013
66a072d
Implemented Table extension methods CompareToProjectionOfSet and Comp…
object May 3, 2013
2061c74
Update Languages.xml
stefc Jul 23, 2013
d156931
Updated Australian English
Daniel15 Aug 28, 2013
59f1708
Merge remote-tracking branch 'upstream/master'
Sep 5, 2013
f21c46d
Merge pull request #324 from joebuschmann/master
gasparnagy Oct 22, 2013
fca81af
Add description to testOutput parameter of nunitexecutionreport
mvalipour Nov 9, 2013
4947891
Add overload to Assist's CreateSet<T> accepting a Func<TableRow,T> to…
Apr 8, 2014
f60e5d4
Specflow Test execution report with tags
kondvilkarrakesh Jun 22, 2014
a069f57
Revert "Specflow Test execution report with tags"
kondvilkarrakesh Jun 22, 2014
ddb20d5
Add "category" nodes for tags through MSTest Report
kondvilkarrakesh Jun 22, 2014
bc81bfa
Update TEHelpers.cs
altamir-junior-dias Jun 24, 2014
e77b4d4
New tests
altamir-junior-dias Jun 24, 2014
cd6bc3b
Adjusts for style points
altamir-junior-dias Jun 25, 2014
3622a6c
Merge pull request #360 from altamir-junior-dias/master
darrencauthon Sep 11, 2014
43d63f3
Merge pull request #348 from bolte-17/master
darrencauthon Sep 11, 2014
bbf3864
Merge pull request #292 from object/master
darrencauthon Sep 11, 2014
988415c
Merge pull request #227 from yazide/master
darrencauthon Sep 11, 2014
949d884
Merge pull request #327 from mvalipour/master
darrencauthon Sep 11, 2014
37b670b
Merge pull request #306 from stefc/patch-1
darrencauthon Sep 11, 2014
721e857
Merge pull request #310 from Daniel15/patch-1
darrencauthon Sep 11, 2014
90602c0
Merge in master, resolve conflict in changelog.
darrencauthon Sep 11, 2014
ff69f0a
Merge pull request #368 from techtalk/nullable_enum_fix
darrencauthon Sep 11, 2014
06c5373
Merge pull request #287 from robfe/master
darrencauthon Sep 11, 2014
fe0b510
Merge pull request #356 from kondvilkarrakesh/master
darrencauthon Sep 18, 2014
add7e36
#328 Anchored the link label correctly
RaringCoder Sep 23, 2014
13552e6
Merge pull request #370 from RaringCoder/master
darrencauthon Sep 23, 2014
6a85639
Fixing CompareToInstance and CompareToSet methods to account for fiel…
umasingareddy Oct 7, 2014
c5e3f6a
Adding back missing files
Oct 13, 2014
c9d25c4
Updating TEHelpers EnumValueRetriever to identify matching properties…
Oct 15, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions Languages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Examples>Beispiele</Examples>
<Given>Angenommen</Given>
<Given>Gegeben sei</Given>
<Given>Gegeben seien</Given>
<When>Wenn</When>
<Then>Dann</Then>
<And>Und</And>
Expand All @@ -111,16 +112,16 @@
<But>But</But>
</Language>
<Language code="en-AU" cultureInfo="en-AU" englishName="English (Australia)">
<Feature>Crikey</Feature>
<Background>Background</Background>
<Scenario>Mate</Scenario>
<ScenarioOutline>Blokes</ScenarioOutline>
<Examples>Cobber</Examples>
<Given>Ya know how</Given>
<When>When</When>
<Then>Ya gotta</Then>
<And>N</And>
<But>Cept</But>
<Feature>Pretty much</Feature>
<Background>First off</Background>
<Scenario>Awww, look mate</Scenario>
<ScenarioOutline>Reckon it's like</ScenarioOutline>
<Examples>You'll wanna</Examples>
<Given>Y'know</Given>
<When>It's just unbelievable</When>
<Then>But at the end of the day I reckon</Then>
<And>Too right</And>
<But>Yeah nah</But>
</Language>
<Language code="en-LOL" cultureInfo="en" englishName="English">
<Feature>OH HAI</Feature>
Expand Down Expand Up @@ -662,4 +663,4 @@
<And>並且</And>
<But>但是</But>
</Language>
</SpecFlowLanguages>
</SpecFlowLanguages>
37 changes: 27 additions & 10 deletions Reporting/MsTestExecutionReport/MsTestToNUnit.xslt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:sfr="urn:TechTalk:SpecFlow.Report"
xmlns:nunit="urn:NUnit"
xmlns:mstest="http://microsoft.com/schemas/VisualStudio/TeamTest/2006"
exclude-result-prefixes="msxsl nunit sfr">
<xsl:output method="xml" />

<xsl:key name="unit-test-result" match="mstest:UnitTestResult" use="@testId"/>
<xsl:key name="unit-test-detail" match="mstest:UnitTest" use="@id"/>

<xsl:template name="get-last-part">
<xsl:param name="text" />
Expand All @@ -33,7 +34,8 @@
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:variable name="startTime" select="mstest:Times/@start" /> <!-- start="2010-06-20T21:54:47.1619417+02:00" -->
<xsl:variable name="startTime" select="mstest:Times/@start" />
<!-- start="2010-06-20T21:54:47.1619417+02:00" -->
<xsl:attribute name="date">
<xsl:value-of select="substring($startTime, 1, 10)"/>
</xsl:attribute>
Expand All @@ -46,7 +48,7 @@
<xsl:variable name="className" select="mstest:TestMethod/@className" />
<xsl:if test="not(preceding-sibling::mstest:UnitTest[mstest:TestMethod/@className=$className])">
<xsl:variable name="unitTests" select="//mstest:UnitTest[mstest:TestMethod/@className=$className]"/>

<nunit:test-suite type="TestFixture" result="Failure" success="False">
<xsl:attribute name="name">
<xsl:call-template name="get-last-part">
Expand Down Expand Up @@ -89,12 +91,12 @@

<xsl:attribute name="time">0.000</xsl:attribute>
<xsl:attribute name="asserts">0</xsl:attribute>

<nunit:results>
<xsl:apply-templates select="$unitTests" />
</nunit:results>
</nunit:test-suite>
</xsl:if>
</xsl:if>
</xsl:for-each>
</nunit:test-results>
</xsl:template>
Expand Down Expand Up @@ -190,7 +192,8 @@
<xsl:variable name="id" select="@id" />
<!--<xsl:variable name="testResult" select="/mstest:TestRun/mstest:Results/mstest:UnitTestResult[@testId=$id]" />-->
<xsl:variable name="testResult" select="key('unit-test-result', $id)" />

<xsl:variable name="testDetail" select="key('unit-test-detail', $id)" />

<xsl:attribute name="name">
<xsl:value-of select="substring-before(mstest:TestMethod/@className, ',')"/>.<xsl:value-of select="@name"></xsl:value-of>
</xsl:attribute>
Expand Down Expand Up @@ -252,7 +255,21 @@
</nunit:message>
</nunit:reason>
</xsl:if>


<xsl:if test="$testDetail/mstest:TestCategory">
<nunit:categories>
<xsl:for-each select="$testDetail/mstest:TestCategory/mstest:TestCategoryItem">
<nunit:category>
<xsl:attribute name="name">
<xsl:value-of select="@TestCategory"/>
</xsl:attribute>
</nunit:category>

</xsl:for-each>

</nunit:categories>
</xsl:if>

<xsl:if test="$testResult/@outcome='Failed'">
<nunit:failure>
<nunit:message>
Expand All @@ -263,8 +280,8 @@
</nunit:stack-trace>
</nunit:failure>
</xsl:if>

</nunit:test-case>
</xsl:template>

</xsl:stylesheet>
18 changes: 14 additions & 4 deletions Runtime/Assist/EnumerableProjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,32 @@ public void Reset()
public class Projection<T>
{
private readonly T item;
private IEnumerable<string> properties;
private readonly IEnumerable<string> properties;

public Projection(T item, IEnumerable<string> properties)
{
this.item = item;
this.properties = properties;
}

public T Value
{
get { return item; }
}

public object this[string key]
{
get { return item.GetMemberValue(key); }
}

public override bool Equals(object obj)
{
if (obj is Projection<T>)
{
var otherProjection = obj as Projection<T>;
if (item != null && otherProjection.item != null)
{
IEnumerable<string> properties = this.properties;
var properties = this.properties;
if (otherProjection.properties != null)
{
if (properties == null)
Expand Down Expand Up @@ -146,8 +156,8 @@ private static bool Compare(T t1, T t2, IEnumerable<string> properties)
if (t1.GetType().GetProperty(property) == null || t2.GetType().GetProperty(property) == null)
return false;

var thisValue = t1.GetPropertyValue(property);
var otherValue = t2.GetPropertyValue(property);
var thisValue = t1.GetMemberValue(property);
var otherValue = t2.GetMemberValue(property);
if (thisValue != null)
{
if (otherValue == null)
Expand Down
41 changes: 27 additions & 14 deletions Runtime/Assist/InstanceComparisonExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using TechTalk.SpecFlow.Assist.ValueComparers;
Expand Down Expand Up @@ -50,10 +50,22 @@ private static string DescribeTheErrorForThisDifference(Difference difference)
private static IEnumerable<Difference> FindAnyDifferences<T>(Table table, T instance)
{
return from row in table.Rows
where ThePropertyDoesNotExist(instance, row) || TheValuesDoNotMatch(instance, row)
where TheMemberDoesNotExist(instance, row) || TheValuesDoNotMatch(instance, row)
select CreateDifferenceForThisRow(instance, row);
}

private static bool TheMemberDoesNotExist<T>(T instance, TableRow row)
{
return ThePropertyDoesNotExist(instance, row) && TheFieldDoesNotExist(instance, row);
}

private static bool TheFieldDoesNotExist<T>(T instance, TableRow row)
{
return instance.GetType().GetFields()
.Any(property => TEHelpers.IsMemberMatchingToColumnName(property, row.Id())) == false;
}


private static bool ThereAreAnyDifferences(IEnumerable<Difference> differences)
{
return differences.Count() > 0;
Expand All @@ -68,7 +80,7 @@ private static bool ThePropertyDoesNotExist<T>(T instance, TableRow row)
private static bool TheValuesDoNotMatch<T>(T instance, TableRow row)
{
var expected = GetTheExpectedValue(row);
var propertyValue = instance.GetPropertyValue(row.Id());
var propertyValue = instance.GetMemberValue(row.Id());

var valueComparers = new IValueComparer[]
{
Expand All @@ -93,19 +105,19 @@ private static string GetTheExpectedValue(TableRow row)

private static Difference CreateDifferenceForThisRow<T>(T instance, TableRow row)
{
if (ThePropertyDoesNotExist(instance, row))
if (TheMemberDoesNotExist(instance, row))
return new Difference
{
Property = row.Id(),
DoesNotExist = true
};
{
Property = row.Id(),
DoesNotExist = true
};

return new Difference
{
Property = row.Id(),
Expected = row.Value(),
Actual = instance.GetPropertyValue(row.Id())
};
{
Property = row.Id(),
Expected = row.Value(),
Actual = instance.GetMemberValue(row.Id())
};
}

private class Difference
Expand Down Expand Up @@ -137,4 +149,5 @@ public ComparisonException(string message)
{
}
}
}
}

53 changes: 53 additions & 0 deletions Runtime/Assist/MemberExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Linq;
using System.Reflection;

namespace TechTalk.SpecFlow.Assist
{
internal static class MemberExtensionMethods
{
public static object GetMemberValue(this object @object, string memberName)
{
var property = GetThePropertyOnThisObject(@object, memberName);

if (property != null)
{
return property.GetValue(@object, null);
}

var field = GetTheFieldOnThisObject(@object, memberName);
return field.GetValue(@object);

}

public static void SetMemberValue(this object @object, string propertyName, object value)
{
var property = GetThePropertyOnThisObject(@object, propertyName);

if (property != null)
{
property.SetValue(@object, value, null);
return;
}

var field = GetTheFieldOnThisObject(@object, propertyName);
field.SetValue(@object, value);

}


private static FieldInfo GetTheFieldOnThisObject(object @object, string fieldName)
{
var type = @object.GetType();
return type.GetFields()
.FirstOrDefault(x => TEHelpers.IsMemberMatchingToColumnName(x, fieldName));

}

private static PropertyInfo GetThePropertyOnThisObject(object @object, string propertyName)
{
var type = @object.GetType();
return type.GetProperties()
.FirstOrDefault(x => TEHelpers.IsMemberMatchingToColumnName(x, propertyName));
}
}
}
47 changes: 44 additions & 3 deletions Runtime/Assist/ProjectionExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

namespace TechTalk.SpecFlow.Assist
{
Expand All @@ -22,6 +24,45 @@ public static IEnumerable<Projection<T>> ToProjectionOfSet<T>(this Table table,
public static IEnumerable<Projection<T>> ToProjectionOfInstance<T>(this Table table, T instance)
{
return new EnumerableProjection<T>(table);
}
}

public static void CompareToProjectionOfSet<T>(
this Table table,
IEnumerable<T> query,
Func<IEnumerable<Projection<T>>, IEnumerable<Projection<T>>, bool> compare)
{
var tableProjection = table.ToProjectionOfSet(query);
var queryProjection = query.ToProjection();
if (!compare(tableProjection, queryProjection))
{
throw new ComparisonException(@"Set projections do not match");
}
}

public static void CompareToProjectionOfSet<T>(
this Table table,
IEnumerable<T> query,
Func<IEnumerable<Projection<T>>, IEnumerable<Projection<T>>, IEnumerable<Projection<T>>> diff,
string identProperty)
{
var tableProjection = table.ToProjectionOfSet(query);
var queryProjection = query.ToProjection();
var setDifference = diff(tableProjection, queryProjection);
if (setDifference.Any())
{
var idents = string.Join(",", setDifference.Select(x => x[identProperty].ToString()).ToArray());
throw new ComparisonException(string.Format(@"The following row projections do not match: {0}", idents));
}
}

public static void CompareToProjectionOfInstance<T>(this Table table, T instance)
{
var tableProjection = table.ToProjectionOfInstance(instance);
var instanceProjection = (new List<T>() {instance}).ToProjection();
if (!tableProjection.Equals(instanceProjection))
{
throw new ComparisonException(@"Instance projections do not match");
}
}
}
}
}
Loading