Closed delta-emil closed 2 years ago
Out of personal interest, (unrelated specifically to this PR): What is the expected outcome if the TableAliases of two properties are matching the same input name? Only the first one gets assigned or all of them?
Out of personal interest, (unrelated specifically to this PR): What is the expected outcome if the TableAliases of two properties are matching the same input name? Only the first one gets assigned or all of them?
When constructing objects (the pre-existing part that I haven't changed), all properties are assigned, and there is a test about it:
[Fact]
public void Property_aliases_allow_multiple_property_population()
{
var table = new Table("AliasOne", "AliasTwo", "AliasThree");
table.AddRow("PropertyOne", "PropertyTwo", "PropertyThree");
var test = table.CreateInstance<AliasedTestObject>();
test.PropertyOne.Should().Be("PropertyOne");
test.AnotherPropertyWithSameAlias.Should().Be("PropertyOne");
}
For the purposes of comparing to existing objects, I made it only use the first property (in no particular order), because it was simplest. Also my thinking was that assigning same alias means you already know they are equal, so no need to check. But now that I'm thinking about it, maybe the more useful thing would be to check all of them.
As you noticed, there's no documentation on the same-alias feature, so I'm not sure.
Thanks for your contribution to SpecFlow. Please submit your contributions to our SpecFlow Community Heroes program at https://specflow.org/community/submit-a-contribution/
This expands the support for
[TableAliases]
to (hopefully) all places where table columns and object properties are being matched. It was previously only supported intable.CreateInstance<T>()
andtable.CreateSet<T>()
Fixes #1384
Types of changes
I'm not entirely certain is this is a bug fix or a new feature. The documentation - https://docs.specflow.org/projects/specflow/en/latest/Bindings/SpecFlow-Assist-Helpers.html - doesn't seem to mention that the effect of
[TableAliases]
is limited toCreateInstance
&CreateSet
, so taking that at face value, this seems to be a bug fix.Checklist: