From 1b46b2db735a1257203df0cc691bd17831d8bb8e Mon Sep 17 00:00:00 2001 From: Jams-H Date: Mon, 17 May 2021 21:51:06 +0100 Subject: [PATCH] Added a table method for checking the requirement level of fields. --- .../Steps/EntitySteps.cs | 21 +++++++++++++++++++ .../EntitySteps.feature | 12 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/bindings/src/Capgemini.PowerApps.SpecFlowBindings/Steps/EntitySteps.cs b/bindings/src/Capgemini.PowerApps.SpecFlowBindings/Steps/EntitySteps.cs index cdbec769..758ea2a8 100644 --- a/bindings/src/Capgemini.PowerApps.SpecFlowBindings/Steps/EntitySteps.cs +++ b/bindings/src/Capgemini.PowerApps.SpecFlowBindings/Steps/EntitySteps.cs @@ -288,6 +288,27 @@ public static void ThenTheFieldIsMandatory(string fieldName, string requirementL fieldContainer.GetAttribute("data-fieldrequirement").Should().Be(requirementLevel == "mandatory" ? 2 : 0, because: $"the field should be {requirementLevel}"); } + /// + /// Asserts that a set of fields are mandatory or optional. + /// + /// Whether the field should be mandatory or optional. + /// The names of the fields. + [Then("the following fields are (mandatory|optional)")] + public static void ThenTheFieldsAreMandatory(string requirementLevel, Table table) + { + if (table is null) + { + throw new ArgumentNullException(nameof(table)); + } + + var fields = table.Rows.Select(x => x.Values.First()); + + foreach (var field in fields) + { + ThenTheFieldIsMandatory(field, requirementLevel); + } + } + /// /// Asserts that a value is shown in a boolean field. /// diff --git a/bindings/tests/Capgemini.PowerApps.SpecFlowBindings.UiTests/EntitySteps.feature b/bindings/tests/Capgemini.PowerApps.SpecFlowBindings.UiTests/EntitySteps.feature index e172cb99..9487cb4a 100644 --- a/bindings/tests/Capgemini.PowerApps.SpecFlowBindings.UiTests/EntitySteps.feature +++ b/bindings/tests/Capgemini.PowerApps.SpecFlowBindings.UiTests/EntitySteps.feature @@ -123,6 +123,18 @@ Scenario: Assert a field is optional Scenario: Assert a field is required Then the 'sb_name' field is mandatory +Scenario: Assert a set of fields are optional + Then the following fields are optional + | fields | + | sb_text | + | sb_number | + | sb_yesno | + +Scenario: Assert a set of fields are mandatory + Then the following fields are mandatory + | fields | + | sb_name | + Scenario Outline: Assert fom notification message Then I can see form notification stating ''