Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand property aliases support (#1384) #2581

Merged

Conversation

delta-emil
Copy link
Contributor

@delta-emil delta-emil commented Apr 8, 2022

This expands the support for [TableAliases] to (hopefully) all places where table columns and object properties are being matched. It was previously only supported in table.CreateInstance<T>() and table.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 to CreateInstance&CreateSet, so taking that at face value, this seems to be a bug fix.

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Performance improvement
  • Refactoring (so no functional change)
  • Other (docs, build config, etc)

Checklist:

  • I've added tests for my code. (most of the time mandatory)
  • I have added an entry to the changelog. (mandatory)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@bollhals
Copy link
Contributor

bollhals commented Apr 8, 2022

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?

@delta-emil
Copy link
Contributor Author

delta-emil commented Apr 11, 2022

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.

@delta-emil delta-emil force-pushed the expand-property-aliases-support branch from d9a46e5 to aa70112 Compare April 11, 2022 15:17
@SabotageAndi
Copy link
Contributor

Thanks for your contribution to SpecFlow.
Please submit your contributions to our SpecFlow Community Heroes program at https://specflow.org/community/submit-a-contribution/

@SabotageAndi SabotageAndi merged commit 5e14699 into SpecFlowOSS:master Apr 12, 2022
gasparnagy added a commit that referenced this pull request Apr 13, 2022
* origin/master:
  expand property aliases support (#1384) (#2581)
  Document how to run tests
  Autofac global container (#2579)
Code-Grump pushed a commit to Code-Grump/SpecFlow that referenced this pull request Mar 29, 2023
Co-authored-by: Emil Tzvetkov <e.tzvetkov@fio.de>
@delta-emil delta-emil deleted the expand-property-aliases-support branch November 11, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: enable table aliases to be used in SpecFlow.Assist CompareToInstance and CompareToSet methods
3 participants