Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a table method for checking the requirement level of fields. #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,27 @@ public static void ThenTheFieldIsMandatory(string fieldName, string requirementL
fieldContainer.GetAttribute<int>("data-fieldrequirement").Should().Be(requirementLevel == "mandatory" ? 2 : 0, because: $"the field should be {requirementLevel}");
}

/// <summary>
/// Asserts that a set of fields are mandatory or optional.
/// </summary>
/// <param name="requirementLevel">Whether the field should be mandatory or optional.</param>
/// <param name="table">The names of the fields.</param>
[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);
}
}

/// <summary>
/// Asserts that a value is shown in a boolean field.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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 <type> form notification stating '<text>'

Expand Down