Step Argument Transforms in Assist

389 views
Skip to first unread message

Darren Cauthon

unread,
Apr 2, 2012, 9:08:37 AM4/2/12
to spec...@googlegroups.com
Can a few people give me a few examples of ways that step argument transformations could be used with the assist helpers?

See, the reason I never put them in there is: I never used them.  I think I've written a handful of these transformations in all of my time using SpecFlow.  I started to take another look at them this week, and I think it would be helpful if I had some real use cases where they'd help.  If anything, just for inspiration. :)


Darren

Darren Bruning

unread,
Apr 2, 2012, 3:52:15 PM4/2/12
to spec...@googlegroups.com
Hi Darren,

Thanks for your interest. My example looks like this:

Given I have the following fert events:
	| Date        | Name | Makeup           | Paddocks | Application Rate |
	| 10 days ago | Urea | 1, 2, 3, 4, 5, 6 | busy     | 100              |
	| 10 days ago | DAP  | 2, 3, 4, 5, 6, 7 | busy     | 1000             |
And I can view paddock history
And I am signed in
When I a view the paddock history for paddock 'busy'
Then I see the following paddock history events:
	| Date        | Particulars line 1    | Amount       |
	| 10 days ago | Urea                  | 100 kg/ha    |
	| 10 days ago | DAP                   | 1000 kg/ha   |
And the step looks like this:
[Then(@"I see the following paddock history events:")]
public void ThenISeeTheFollowingPaddockHistoryEvents(Table table)
{
	// Convert table to a strongly-typed row set
	var expectedEventRows = table.CreateSet<PaddockHistoryTableRow>();
 
	// Process the relative date strings into real dates 
	// (this is where Step Argument Transforms on the table cells would be awesome)
	var expectedEventsWithActualDates = expectedEventRows.Select(r => new
	{
		Date = r.Date.ParseRelativeDayDescription(), 
		ParticularsLine1 = r.ParticularsLine1, 
		Amount = r.Amount
	}).ToList();
 
	// Get my actuals
	var actualEvents = _paddockHistoryWizard.EventsPane.PaddockHistoryEvents;
 
	// Manually compare actuals with expecteds
	Assert.AreEqual(expectedEventsWithActualDates.Count, actualEvents.Count);
	foreach (var expected in expectedEventsWithActualDates)
	{
		Assert.IsTrue(actualEvents.Any(actual => 
			actual.Amount == expected.Amount
			&& actual.Date == expected.Date 
			&& actual.ParticularsLine1 == expected.ParticularsLine1));
	}
}
Hope that is inspiring :)
Cheers,
Darren B.
--
Darren Bruning
441 Whakamarama Rd
RD6 Tauranga
07 552 5459
027 552 5459

Satyabrata Saha

unread,
Sep 11, 2014, 3:26:05 AM9/11/14
to spec...@googlegroups.com, dar...@bruning.net.nz, satyabr...@outlook.com
I would like to know how to provide StepArgumentTransformation in a table cell.Could you please extend some help?Basically, I want to transform the Date column in the datatable .For example:-The its 'today'-then it  would generate current date.

Erik

unread,
Nov 11, 2016, 5:29:16 PM11/11/16
to SpecFlow, dar...@bruning.net.nz, satyabr...@outlook.com
Did anyone ever figure this out?  I posted a question to StackOverflow as well, as the application of StepArgumentTransformations to table cell data would be very very nice.  
Reply all
Reply to author
Forward
0 new messages