public Specification(string name, Then then, bool isIgnored, FieldInfo fieldInfo) { _name = name; _then = then; _isIgnored = isIgnored; _fieldInfo = fieldInfo; }
private static ScenarioStep ConvertToCompatibleStep(SpecFlowStep step) { ScenarioStep result = null; if (step.StepKeyword == StepKeyword.Given) result = new Given {StepKeyword = step.StepKeyword }; else if (step.StepKeyword == StepKeyword.When) result = new When {StepKeyword = step.StepKeyword }; else if (step.StepKeyword == StepKeyword.Then) result = new Then {StepKeyword = step.StepKeyword }; else if (step.StepKeyword == StepKeyword.And) result = new And { StepKeyword = step.StepKeyword }; else if (step.StepKeyword == StepKeyword.But) result = new But {StepKeyword = step.StepKeyword }; if (result == null) throw new NotSupportedException(); result.Keyword = step.Keyword; result.Text = step.Text; result.ScenarioBlock = step.ScenarioBlock; result.MultiLineTextArgument = step.Argument is global::Gherkin.Ast.DocString ? ((global::Gherkin.Ast.DocString) step.Argument).Content : null; result.TableArg = step.Argument is global::Gherkin.Ast.DataTable ? ConvertToCompatibleTable(((global::Gherkin.Ast.DataTable) step.Argument).Rows) : null; result.FilePosition = ConvertToCompatibleFilePosition(step.Location); return result; }
public ThenSemantics Then(Then then) { var text = metadataParser.TranslateToText(then); if (text == string.Empty) text = GetCallersMethodName(); return Then(text, () => { then(); }); }
public BehaviorSpecification(string name, Then then, bool isIgnored, FieldInfo fieldInfo, Context context, Behavior behavior) : base(name, then, isIgnored, fieldInfo) { _contextInstance = context.Instance; _behaviorInstance = behavior.Instance; _mapper = new ConventionMapper(); }
public void The_mismatch_exception_message_contains_information_about_the_mismatch() { Given.We_have_mismatch_exception_for_a_specific_comparison(); When.We_read_the_message_of_the_exception(); Then.It_tells_us_what_the_difference_is(); }
public void Comparing_true_and_true_does_not_yield_any_exception() { Given.We_want_to_compare_two_objects(); When.We_compare_true_and_true(); Then.Nothing(); }
public void Can_ignore_a_specific_property_on_a_specific_object_in_a_list() { Given.A_lambda_representation_of_a_property_we_wish_to_ignore(); When.We_tell_the_comparator_to_use_that_on_a_specific_object_when_comparing_two_lists(); Then.Nothing(); }
public void area_behavior_on_model() { AbilityConfiguration.ConfigureWith(c => c.Allow("area/view").On("customer")); Then.IShouldNotBeAbleTo("view", new CustomerDto()); Then.IShouldBeAbleTo("area/view", new CustomerDto()); }
public void default_area_behavior() { AbilityConfiguration.ConfigureWith(c => c.Allow("area/view").On("customer")); Then.IShouldNotBeAbleTo("view", "customer"); Then.IShouldBeAbleTo("area/view", "customer"); }
private ExpressionNode ParseCallExpression() { var left = ParsePrimaryExpression(); if (IsSymbol('(')) { if (left is Variable v) { var t = (TweenNode)null; if (CallTween.IsValidId(v.Value)) { var args = ParseArguments(); t = new CallTween(v.Value, args); } else if (v.Value == "Active") { var args = ParseArguments(); return(new SetActive(args)); } else if (v.Value == "Callback") { ParseArguments(); return(new Callback()); } else { SyntaxError($"{v.Value} is not valid tween name"); } while (IsSymbol('.')) { NextToken(); var member = ParsePrimaryExpression(); if (member is Variable m) { if (!IsSymbol('(')) { SyntaxError("Missing '(' after method access"); } if (m.Value == "Then") { NextToken(); var body = ParseStatement(); if (!IsSymbol(')')) { SyntaxError("Missing ')' after Then body"); } NextToken(); t = new Then(t, body); } else { var args = ParseArguments(); switch (m.Value) { case "From": { t = new From(t, args, false); break; } case "FromRelative": { t = new From(t, args, true); break; } case "Delay": { t = new Delay(t, args); break; } case "Animate": { t = new Animate(t, args); break; } case string name when name.StartsWith("Ease"): { if (!Ease.IsValidName(name)) { SyntaxError($"{name} is not valid easing name"); } t = new Ease(name, t, args); break; } default: SyntaxError($"{m.Value} is not valid method name"); break; } } } else { SyntaxError("Invalid method access"); } } return(t); } else { SyntaxError("Invalid function call"); } } return(left); }
public void WhenShellLoads_MessageShouldBeInitializing() { Assert.IsTrue(Then.MessageIs("Initializing...")); }
// $ANTLR end "steps" // $ANTLR start "step" // SpecFlowLangWalker.g:156:1: step returns [ScenarioStep step] : ( ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) ); public ScenarioStep step() // throws RecognitionException [1] { ScenarioStep step = default(ScenarioStep); Text text_ = default(Text); MultilineText mlt_ = default(MultilineText); Table table_ = default(Table); FilePosition fp_ = default(FilePosition); try { // SpecFlowLangWalker.g:160:5: ( ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) | ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) ) int alt24 = 5; switch ( input.LA(1) ) { case GIVEN: { alt24 = 1; } break; case WHEN: { alt24 = 2; } break; case THEN: { alt24 = 3; } break; case AND: { alt24 = 4; } break; case BUT: { alt24 = 5; } break; default: NoViableAltException nvae_d24s0 = new NoViableAltException("", 24, 0, input); throw nvae_d24s0; } switch (alt24) { case 1 : // SpecFlowLangWalker.g:160:9: ^( GIVEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) { Match(input,GIVEN,FOLLOW_GIVEN_in_step1055); Match(input, Token.DOWN, null); PushFollow(FOLLOW_text_in_step1071); text_ = text(); state.followingStackPointer--; // SpecFlowLangWalker.g:162:17: (mlt_= multilineText )? int alt14 = 2; int LA14_0 = input.LA(1); if ( (LA14_0 == MULTILINETEXT) ) { alt14 = 1; } switch (alt14) { case 1 : // SpecFlowLangWalker.g:162:17: mlt_= multilineText { PushFollow(FOLLOW_multilineText_in_step1087); mlt_ = multilineText(); state.followingStackPointer--; } break; } // SpecFlowLangWalker.g:163:19: (table_= table )? int alt15 = 2; int LA15_0 = input.LA(1); if ( (LA15_0 == TABLE) ) { alt15 = 1; } switch (alt15) { case 1 : // SpecFlowLangWalker.g:163:19: table_= table { PushFollow(FOLLOW_table_in_step1104); table_ = table(); state.followingStackPointer--; } break; } PushFollow(FOLLOW_fileposition_in_step1121); fp_ = fileposition(); state.followingStackPointer--; Match(input, Token.UP, null); step = new Given(text_, mlt_, table_); } break; case 2 : // SpecFlowLangWalker.g:169:9: ^( WHEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) { Match(input,WHEN,FOLLOW_WHEN_in_step1152); Match(input, Token.DOWN, null); PushFollow(FOLLOW_text_in_step1168); text_ = text(); state.followingStackPointer--; // SpecFlowLangWalker.g:171:17: (mlt_= multilineText )? int alt16 = 2; int LA16_0 = input.LA(1); if ( (LA16_0 == MULTILINETEXT) ) { alt16 = 1; } switch (alt16) { case 1 : // SpecFlowLangWalker.g:171:17: mlt_= multilineText { PushFollow(FOLLOW_multilineText_in_step1184); mlt_ = multilineText(); state.followingStackPointer--; } break; } // SpecFlowLangWalker.g:172:19: (table_= table )? int alt17 = 2; int LA17_0 = input.LA(1); if ( (LA17_0 == TABLE) ) { alt17 = 1; } switch (alt17) { case 1 : // SpecFlowLangWalker.g:172:19: table_= table { PushFollow(FOLLOW_table_in_step1201); table_ = table(); state.followingStackPointer--; } break; } PushFollow(FOLLOW_fileposition_in_step1218); fp_ = fileposition(); state.followingStackPointer--; Match(input, Token.UP, null); step = new When(text_, mlt_, table_); } break; case 3 : // SpecFlowLangWalker.g:178:9: ^( THEN text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) { Match(input,THEN,FOLLOW_THEN_in_step1249); Match(input, Token.DOWN, null); PushFollow(FOLLOW_text_in_step1265); text_ = text(); state.followingStackPointer--; // SpecFlowLangWalker.g:180:17: (mlt_= multilineText )? int alt18 = 2; int LA18_0 = input.LA(1); if ( (LA18_0 == MULTILINETEXT) ) { alt18 = 1; } switch (alt18) { case 1 : // SpecFlowLangWalker.g:180:17: mlt_= multilineText { PushFollow(FOLLOW_multilineText_in_step1281); mlt_ = multilineText(); state.followingStackPointer--; } break; } // SpecFlowLangWalker.g:181:19: (table_= table )? int alt19 = 2; int LA19_0 = input.LA(1); if ( (LA19_0 == TABLE) ) { alt19 = 1; } switch (alt19) { case 1 : // SpecFlowLangWalker.g:181:19: table_= table { PushFollow(FOLLOW_table_in_step1298); table_ = table(); state.followingStackPointer--; } break; } PushFollow(FOLLOW_fileposition_in_step1315); fp_ = fileposition(); state.followingStackPointer--; Match(input, Token.UP, null); step = new Then(text_, mlt_, table_); } break; case 4 : // SpecFlowLangWalker.g:187:9: ^( AND text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) { Match(input,AND,FOLLOW_AND_in_step1346); Match(input, Token.DOWN, null); PushFollow(FOLLOW_text_in_step1362); text_ = text(); state.followingStackPointer--; // SpecFlowLangWalker.g:189:17: (mlt_= multilineText )? int alt20 = 2; int LA20_0 = input.LA(1); if ( (LA20_0 == MULTILINETEXT) ) { alt20 = 1; } switch (alt20) { case 1 : // SpecFlowLangWalker.g:189:17: mlt_= multilineText { PushFollow(FOLLOW_multilineText_in_step1378); mlt_ = multilineText(); state.followingStackPointer--; } break; } // SpecFlowLangWalker.g:190:19: (table_= table )? int alt21 = 2; int LA21_0 = input.LA(1); if ( (LA21_0 == TABLE) ) { alt21 = 1; } switch (alt21) { case 1 : // SpecFlowLangWalker.g:190:19: table_= table { PushFollow(FOLLOW_table_in_step1395); table_ = table(); state.followingStackPointer--; } break; } PushFollow(FOLLOW_fileposition_in_step1412); fp_ = fileposition(); state.followingStackPointer--; Match(input, Token.UP, null); step = new And(text_, mlt_, table_); } break; case 5 : // SpecFlowLangWalker.g:196:9: ^( BUT text_= text (mlt_= multilineText )? (table_= table )? fp_= fileposition ) { Match(input,BUT,FOLLOW_BUT_in_step1443); Match(input, Token.DOWN, null); PushFollow(FOLLOW_text_in_step1459); text_ = text(); state.followingStackPointer--; // SpecFlowLangWalker.g:198:17: (mlt_= multilineText )? int alt22 = 2; int LA22_0 = input.LA(1); if ( (LA22_0 == MULTILINETEXT) ) { alt22 = 1; } switch (alt22) { case 1 : // SpecFlowLangWalker.g:198:17: mlt_= multilineText { PushFollow(FOLLOW_multilineText_in_step1475); mlt_ = multilineText(); state.followingStackPointer--; } break; } // SpecFlowLangWalker.g:199:19: (table_= table )? int alt23 = 2; int LA23_0 = input.LA(1); if ( (LA23_0 == TABLE) ) { alt23 = 1; } switch (alt23) { case 1 : // SpecFlowLangWalker.g:199:19: table_= table { PushFollow(FOLLOW_table_in_step1492); table_ = table(); state.followingStackPointer--; } break; } PushFollow(FOLLOW_fileposition_in_step1509); fp_ = fileposition(); state.followingStackPointer--; Match(input, Token.UP, null); step = new But(text_, mlt_, table_); } break; } step.FilePosition = fp_; } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { } return step; }
public void a_simple_ability_allows_its_action() { AbilityConfiguration.ConfigureWith(c => c.AllowTo("view", "customer")); Then.IShouldBeAbleTo("view", "customer"); }
public void a_null_abiltiy_doesnt_allow_anything() { Then.IShouldNotBeAbleTo("view", "customer"); }
public void WhenSharingUri_ShouldSetTitle() { Assert.IsTrue(Then.TitleIs(_args, "Bing Image Search Link")); }
public async void WhenSharingUri_ShouldSetUri() { Assert.IsTrue(await Then.UriIs(_args, _uri)); }
public void WhenShellBingIsUnavailable_StatusCommandShouldShowSettings() { Given.BingIsUnavailable(); When.ExecutingStatusCommand(); Assert.IsTrue(Then.MessageSent <ShowSettingsMessage>()); }
public void We_do_not_want_to_compare_the_Capacity_or_other_properties_when_comparing_IEnumerables() { Given.We_want_to_compare_two_objects(); When.We_compare_two_lists_with_equal_objects_but_different_capacity(); Then.Nothing(); }
public AndSemantics And(Then then) { semanticModel.Assert(metadataParser.TranslateToText(then), () => { then(); }); return new AndSemantics(this, semanticModel); }
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) { TResult result = Convert(CSharp.CastOrDefault <TValue>(value)); return(Then == null ? result : Then.Convert(result, targetType, ThenParameter, culture)); }
public ThenSemantics Then(Then then) { return scenario.Then(then); }
public void WhenSavingImage_ShouldSendSaveMessage() { When.Saving(); Assert.IsTrue(Then.Message <SaveImageMessage>().SentWith(_image)); }
public ScenarioStep CreateStep(string keyword, StepKeyword stepKeyword, string text, FilePosition position, ScenarioBlock scenarioBlock) { ScenarioStep step; switch (stepKeyword) { case StepKeyword.Given: step = new Given(); break; case StepKeyword.When: step = new When(); break; case StepKeyword.Then: step = new Then(); break; case StepKeyword.And: step = new And(); break; case StepKeyword.But: step = new But(); break; default: throw new NotSupportedException(); } step.Keyword = keyword; step.Text = text; step.FilePosition = position; step.ScenarioBlock = scenarioBlock; step.StepKeyword = stepKeyword; return step; }
public void WhenSettingLockScreen_ShouldSendSetLockScreenMessage() { When.SettingLockScreen(); Assert.IsTrue(Then.Message <SetLockScreenMessage>().SentWith(_image)); }
public void area_is_case_insensitive() { AbilityConfiguration.ConfigureWith(c => c.Allow("aREa/vIEw").On("customer")); Then.IShouldBeAbleTo("AreA/View", "customer"); }
public void WhenSettingTile_ShouldSendSetTileMessage() { When.SettingTile(); Assert.IsTrue(Then.Message <UpdateTileMessage>().SentWith(_image)); }
public void default_area_behavior_on_command_with_area() { AbilityConfiguration.ConfigureWith(c => c.Allow("area/update").On("customer")); Then.IShouldNotBeAbleToExecute("UpdateCustomerCommand"); Then.IShouldBeAbleToExecute("area/UpdateCustomerCommand"); }
public void WhenSharing_ShouldSendShowShareUiMessage() { When.Sharing(); Assert.IsTrue(Then.MessageSent <ShowShareUiMessage>()); }
public void Can_apply_ignore_functionality_to_all_instances_in_an_IEnumerable() { Given.A_lambda_representation_of_a_property_we_wish_to_ignore(); When.We_tell_the_comparator_to_use_that_on_all_elements_in_an_IEnumerable_when_comparing(); Then.Nothing(); }
public void WhenShowingSettings_ShouldSendShowSettingsMessage() { When.ShowingSettings(); Assert.IsTrue(Then.MessageSent <ShowSettingsMessage>()); }
public void Comparing_true_and_false_yields_an_exception() { Given.We_want_to_compare_two_objects(); When.We_compare_true_and_false(); Then.We_get_the_appropriate_exception(); }
public void WhenUpdatingTileWithSmallImage_ShouldHaveImageSetToMediaUrl() { Assert.IsTrue(Then.TileImageSetTo(_image.MediaUrl)); Assert.IsTrue(Then.SquareTileImageSetTo(_image.MediaUrl)); }
public void Do_not_follow_circular_references() { Given.We_want_to_compare_two_objects(); When.We_compare_two_objects_with_circular_references(); Then.Nothing(); }
public void WhenUpdatingTileWithSmallImage_ShouldHaveTitleSetToTitle() { Assert.IsTrue(Then.TileTitleSetTo(_image.Title)); }
public void Comparing_two_lists_of_different_objects_yields_all_nested_differences() { Given.We_want_to_compare_two_objects(); When.We_compare_two_lists_with_two_objects_each_that_differ_in_two_properties_each(); Then.The_exception_message_contains_all_four_differences(); }
public void Observation(Then observation) { if (Exception != null) { throw Exception; } observation(); }
public void WhenUpdatingTileWithLargeImage_ShouldHaveImageSetToThumbnailImage() { Assert.IsTrue(Then.TileImageSetTo(_image.Thumbnail.MediaUrl)); Assert.IsTrue(Then.SquareTileImageSetTo(_image.Thumbnail.MediaUrl)); }
private ScenarioStep Clone(ScenarioStep step) { ScenarioStep newStep = null; if (step is Given) newStep = new Given(); else if (step is When) newStep = new When(); else if (step is Then) newStep = new Then(); else if (step is And) newStep = new And(); else if (step is But) newStep = new But(); Debug.Assert(newStep != null); newStep.Text = step.Text; newStep.MultiLineTextArgument = step.MultiLineTextArgument; newStep.TableArg = Clone(step.TableArg); return newStep; }
public void an_ability_can_be_checked_with_an_entity_case_insensitive() { AbilityConfiguration.ConfigureWith(c => c.AllowTo("view", "customer")); Then.IShouldBeAbleTo("view", new Customer()); }
public void ThrowNewException_Returns_PostHandlingAction_ThrowNewException() { Assert.AreEqual( PostHandlingAction.ThrowNewException, Then.ThrowNewException()); }
private ScenarioStep CloneTo(ScenarioStep step, string currentBlock) { ScenarioStep newStep = null; if (currentBlock == "When") newStep = new When(); else if (currentBlock == "Then") newStep = new Then(); else // Given or empty newStep = new Given(); Debug.Assert(newStep != null); newStep.Text = step.Text; newStep.MultiLineTextArgument = step.MultiLineTextArgument; newStep.TableArg = Clone(step.TableArg); return newStep; }
public ThenSemantics And(Then then) { return And(metadataParser.TranslateToText(then), () => { then(); }); }