Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcusoftnet/specflow.assist.dynamic
Extension methods to create dynamic objects from SpecFlow tables
https://github.com/marcusoftnet/specflow.assist.dynamic
c-sharp cucumber specflow specflow-table
Last synced: 3 months ago
JSON representation
Extension methods to create dynamic objects from SpecFlow tables
- Host: GitHub
- URL: https://github.com/marcusoftnet/specflow.assist.dynamic
- Owner: marcusoftnet
- License: mit
- Created: 2011-08-28T18:55:39.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2020-09-21T17:45:36.000Z (over 4 years ago)
- Last Synced: 2024-10-12T04:03:03.535Z (3 months ago)
- Topics: c-sharp, cucumber, specflow, specflow-table
- Language: C#
- Homepage: https://github.com/marcusoftnet/SpecFlow.Assist.Dynamic
- Size: 12.6 MB
- Stars: 51
- Watchers: 10
- Forks: 27
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# SpecFlow.Assist.Dynamic
SpecFlow.Assist.Dynamic is a couple of simple extension methods for the SpecFlow Table object that helps you to write less code.
What would you rather write?
This:
```c#
[Binding]
public class StepsUsingStaticType
{
private Person _person;[Given(@"I create an instance from this table")]
public void GivenICreateAnInstanceFromThisTable(Table table)
{
_person = table.CreateInstance();
}[Then(@"the Name property on Person should equal '(.*)'")]
public void PersonNameShouldBe(string expectedValue)
{
Assert.AreEqual(expectedValue, _person.Name);
}
}// And then make sure to not forget defining a separate Person class for testing,
// since you don't want to reuse the one your system under test is using - that's bad practice// Should probably be in another file too...
// might need unit tests if the logic is complicated
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public DateTime BirthDate { get; set; }
public double LengthInMeters { get; set; }
}
```
Or this:
```c#
[Binding]
public class StepsUsingDynamic
{
private dynamic _instance;[Given(@"I create an instance from this table")]
public void c(dynamic instance) { _instance = instance; }[Then(@"the Name property should equal '(.*)'")]
public void NameShouldBe(string expectedValue) { Assert.AreEqual(expectedValue, _instance.Name); }
}
```
The later version uses SpecFlow.Assist.Dynamic. Shorter, sweater and more fun!> well, this is may be one of the best usecase for dynamic i have ever seen
>> A happy SpecFlow.Assists.Dynamic userFull [documentation on the wiki](https://github.com/marcusoftnet/SpecFlow.Assist.Dynamic/wiki/Documentation)