Coder Social home page Coder Social logo

samjongenelen / specflow.assist.dynamic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcusoftnet/specflow.assist.dynamic

0.0 2.0 0.0 12.92 MB

Extension methods to create dynamic objects from SpecFlow tables

License: MIT License

C# 65.79% Batchfile 0.19% Gherkin 34.01%

specflow.assist.dynamic's Introduction

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:

[Binding]
public class StepsUsingStaticType
{
    private Person _person;

    [Given(@"I create an instance from this table")]
    public void GivenICreateAnInstanceFromThisTable(Table table)
    {
        _person = table.CreateInstance<Person>();
    }

    [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:

[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!

Full documentation on the wiki

specflow.assist.dynamic's People

Contributors

marcusoftnet avatar kntajus avatar srkl avatar tjdekker avatar romerod avatar

Watchers

James Cloos avatar Sam Jongenelen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.