Skip to content

Instantly share code, notes, and snippets.

@darrencauthon
Created October 11, 2011 03:44
Show Gist options
  • Save darrencauthon/1277219 to your computer and use it in GitHub Desktop.
Save darrencauthon/1277219 to your computer and use it in GitHub Desktop.
Loose Guid support in SpecFlow?
Feature: Loose Guids
Scenario: Sample loose guid
Given the account repository has the following accounts
| Id | LastName |
| 1 | Galt |
| 2 | Roark |
When I press the delete account '1' button
Then I should have the following accounts
| Id | LastName |
| 2 | Roark |
using System;
using System.Collections.Generic;
using System.Linq;
using TechTalk.SpecFlow;
using TechTalk.SpecFlow.Assist;
namespace TestSamples
{
[Binding]
public class TestingSteps
{
private List<Account> accounts;
[Given(@"the account repository has the following accounts")]
public void GivenTheAccountRepositoryHasTheFollowingAccounts(Table table)
{
accounts = table.CreateSet<Account>().ToList();
}
[When(@"I press the delete account '(.*)' button")]
public void WhenIPressTheDeleteAccount1Button(Guid id)
{
accounts.RemoveAll(x => x.Id == id);
}
[Then(@"I should have the following accounts")]
public void ThenIShouldHaveTheFollowingAccounts(Table table)
{
table.CompareToSet(accounts);
}
}
public class Account
{
public Guid Id { get; set; }
public string LastName { get; set; }
}
}
@marcusoftnet
Copy link

Nice Darren!

I've heard a lot of people stumbling on this one. Especially if you do CQRS with ES it's probably a common problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment