Tables of values for when statements

2 views
Skip to first unread message

David Koontz

unread,
Nov 25, 2012, 6:54:05 PM11/25/12
to stor...@googlegroups.com
I know Storevil isn't getting a lot of traffic or updates lately but I just found it and it's really perfect for my needs.  I've been able to figure out everything thus far, except one thing which is using a table of values as input to a when statement.  Using the table for a given works fine:

Scenario: Removing a specific card from a hand

Given the following hand
  |Name| 
  |Blue1| 
  |Red1|
  |Green1| 
  |Yellow1| 
When "Red1" is removed from the hand 
Then the cards should be 
  |Name| 
  |Blue1| 
  |Green1| 
  |Yellow1|

The "Given the following hand" method is:

public void Given_the_following_hand(Card[] cards) {
  hand = new Hand(cards); 
}

The Card class has a public string Name property.  The problem comes in the "Then the cards should be" method which had this signature:

public void Then_the_cards_should_be(Card[] cards)

So even though it's exactly the same as the Given, the matcher is not working.  Running with --debug shows that as soon as the ReflectionMatcher for the Given is added, a match is found, but the same is not true for the Then.  So I'm a bit confused as I was under the assumption that there is nothing magical about given/when/then and it's just naming so both should work the same.  Any ideas on where I could look to fix either my own code or go into the corevil code to patch it?

[ScenarioLineExecter.ExecuteLine] - Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|
[Interpreting] - Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|
[ScenarioInterpreterForType] - Interpreting 'Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|' with type:CardPileContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_1_card
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_all_the_cards_are_removed_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_the_card_pile_is_shuffled
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_pile_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_I_should_see_that_a_NotEnoughCardsException_error_has_occured
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_first_card_drawn_should_be_the_added_card
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_order_of_the_cards_in_the_pile_should_not_be_the_same
[ScenarioInterpreterForType] - Interpreting 'Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|' with type:HandContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_hand
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_hand_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_hand
[ScenarioInterpreterForType] - Exact match
[ReflectionMatcherFactory] - Added reflection matcher: Given_two_hands_each_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_cardName_is_removed_from_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_all_cards_are_removed_from_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_a_card_is_discarded_randomly_from_each_hand
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_hand_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_cards_should_be
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_hands_should_have_different_cards
[ScenarioInterpreterForType] - Interpreting 'Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|' with type:Object
[EventBus] - Raising StorEvil.Events.MatchingMemberFound
[EventBus] - ... handled by: StorEvil.Interpreter.MostRecentlyUsedContext
[EventBus] - Raising StorEvil.Events.LinePassed
Given the following hand
|Name|
|Blue1|
|Red1|
|Green1|
|Yellow1|
[EventBus] - ... handled by: StorEvil.ResultListeners.ConsoleResultListener
[ScenarioLineExecter.ExecuteLine] - When "Red1" is removed from the hand
[Interpreting] - When "Red1" is removed from the hand
[ScenarioInterpreterForType] - Interpreting 'When "Red1" is removed from the hand' with type:CardPileContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_1_card
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_all_the_cards_are_removed_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_the_card_pile_is_shuffled
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_pile_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_I_should_see_that_a_NotEnoughCardsException_error_has_occured
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_first_card_drawn_should_be_the_added_card
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_order_of_the_cards_in_the_pile_should_not_be_the_same
[ScenarioInterpreterForType] - Interpreting 'When "Red1" is removed from the hand' with type:HandContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_hand
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_hand_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_hand
[ReflectionMatcherFactory] - Added reflection matcher: Given_two_hands_each_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_cardName_is_removed_from_the_hand
[ScenarioInterpreterForType] - Exact match
[ReflectionMatcherFactory] - Added reflection matcher: When_all_cards_are_removed_from_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_a_card_is_discarded_randomly_from_each_hand
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_hand_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_cards_should_be
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_hands_should_have_different_cards
[ScenarioInterpreterForType] - Interpreting 'When "Red1" is removed from the hand' with type:Object
[EventBus] - Raising StorEvil.Events.MatchingMemberFound
[EventBus] - ... handled by: StorEvil.Interpreter.MostRecentlyUsedContext
[EventBus] - Raising StorEvil.Events.LinePassed
When "Red1" is removed from the hand
[EventBus] - ... handled by: StorEvil.ResultListeners.ConsoleResultListener
[ScenarioLineExecter.ExecuteLine] - Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|
[Interpreting] - Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|
[ScenarioInterpreterForType] - Interpreting 'Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|' with type:CardPileContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_1_card
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_card_pile_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_card_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_top_of_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_drawn_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_all_the_cards_are_removed_from_the_pile
[ReflectionMatcherFactory] - Added reflection matcher: When_the_card_pile_is_shuffled
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_pile_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_I_should_see_that_a_NotEnoughCardsException_error_has_occured
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_first_card_drawn_should_be_the_added_card
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_order_of_the_cards_in_the_pile_should_not_be_the_same
[ScenarioInterpreterForType] - Interpreting 'Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|' with type:HandContext
[ReflectionMatcherFactory] - Added reflection matcher: Given_an_empty_hand
[ReflectionMatcherFactory] - Added reflection matcher: Given_a_hand_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: Given_the_following_hand
[ReflectionMatcherFactory] - Added reflection matcher: Given_two_hands_each_with_numCards_cards
[ReflectionMatcherFactory] - Added reflection matcher: When_1_card_is_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_numCards_cards_are_added_to_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_cardName_is_removed_from_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_all_cards_are_removed_from_the_hand
[ReflectionMatcherFactory] - Added reflection matcher: When_a_card_is_discarded_randomly_from_each_hand
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_number_of_cards_in_the_hand_should_be_numCards
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_cards_should_be
[ReflectionMatcherFactory] - Added reflection matcher: Then_the_hands_should_have_different_cards
[ScenarioInterpreterForType] - Interpreting 'Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|' with type:Object
[ScenarioInterpreter] - no match: Then the cards should be
|Name|
|Blue1|
|Green1|
|Yellow1|
[EventBus] - Raising StorEvil.Events.LinePending

Dave Foley

unread,
Dec 2, 2012, 8:34:32 PM12/2/12
to stor...@googlegroups.com
Hey there. 

Sorry for the delay in response. 

I wonder if there might be a bug related to parsing the last step in a scenario. 
There is nothing special about "Then" vs. any other word as far as the parsing goes.
I don't have time to look into this right now, but you could test the hypothesis by adding another step at the end. If you try this, let me know what you find.

Sorry I don't have more bandwidth at the moment to look at this. I would enjoy diving into StorEvil again, and this seems like a bug that should be fixed.

Dave
Reply all
Reply to author
Forward
0 new messages