1- using System ;
2- using System . Linq ;
1+ using System . Linq ;
32using Behavioral . Automation . Elements ;
43using Behavioral . Automation . FluentAssertions ;
54using Behavioral . Automation . Model ;
5+ using Behavioral . Automation . Services ;
66using JetBrains . Annotations ;
77using TechTalk . SpecFlow ;
88
99namespace Behavioral . Automation . Bindings
10- { /// <summary>
10+ {
11+ /// <summary>
1112 /// Bindings for element's attributes testing
1213 /// </summary>
1314 [ Binding ]
1415 public sealed class AttributeBinding
1516 {
16- private readonly ITestRunner _runner ;
17+ private readonly RunnerService _runnerService ;
18+ private readonly ScenarioContext _scenarioContext ;
1719
18- public AttributeBinding ( [ NotNull ] ITestRunner runner )
20+ public AttributeBinding ( [ NotNull ] RunnerService runnerService , [ NotNull ] ScenarioContext scenarioContext )
1921 {
20- _runner = runner ;
22+ _runnerService = runnerService ;
23+ _scenarioContext = scenarioContext ;
2124 }
2225
2326 /// <summary>
@@ -41,18 +44,7 @@ public void CheckElementIsDisabled(
4144 }
4245
4346 /// <summary>
44- /// Transform "enabled" or "disabled" string into bool value
45- /// </summary>
46- /// <param name="enabled">"enabled" or "disabled" string</param>
47- /// <returns></returns>
48- [ StepArgumentTransformation ( "(enabled|disabled)" ) ]
49- public bool ConvertEnabledState ( [ NotNull ] string enabled )
50- {
51- return enabled == "enabled" ;
52- }
53-
54- /// <summary>
55- /// Check that multiple elements are disabled or enabled in "Then" steps
47+ /// Check that multiple elements are disabled or enabled
5648 /// </summary>
5749 /// <param name="behavior">Assertion behavior (instant or continuous)</param>
5850 /// <param name="enabled">Elements expected status (enabled or disabled)</param>
@@ -63,28 +55,13 @@ public bool ConvertEnabledState([NotNull] string enabled)
6355 /// | "Test1" input |
6456 /// | "Test2" input |
6557 /// </example>
58+ [ Given ( "the following controls (are|are not|become|become not) (enabled|disabled)" ) ]
6659 [ Then ( "the following controls should (be|be not|become|become not) (enabled|disabled):" ) ]
67- public void CheckThenControlTypeCollectionShown ( [ NotNull ] string behavior , string enabled , [ NotNull ] Table table )
60+ public void CheckControlTypeCollectionShown ( [ NotNull ] string behavior , string enabled , [ NotNull ] Table table )
6861 {
69- behavior = $ "should { behavior } ";
70- CheckControlTypeCollectionEnabled ( behavior , enabled , table , _runner . Then ) ;
71- }
62+ behavior = _runnerService . ConvertBehaviorForGroupRun ( _scenarioContext , behavior ) ;
7263
73- /// <summary>
74- /// Check that multiple elements are disabled or enabled in "Given" or "When" steps
75- /// </summary>
76- /// <param name="behavior">Assertion behavior (instant or continuous)</param>
77- /// <param name="enabled">>Elements expected status (enabled or disabled)</param>
78- /// <param name="table">Specflow table with element names to be tested</param>
79- [ Given ( "the following controls (are|are not|become| become not) (enabled|disabled):" ) ]
80- [ When ( "the following controls (are|are not|become| become not) (enabled|disabled):" ) ]
81- public void CheckGivenControlTypeCollectionEnabled ( [ NotNull ] string behavior , string enabled , [ NotNull ] Table table )
82- {
83- if ( behavior . Contains ( "are" ) )
84- {
85- behavior = behavior . Replace ( "are" , "is" ) ;
86- }
87- CheckControlTypeCollectionEnabled ( behavior , enabled , table , _runner . Given ) ;
64+ CheckControlTypeCollectionEnabled ( behavior , enabled , table ) ;
8865 }
8966
9067 /// <summary>
@@ -97,11 +74,11 @@ public void CheckGivenControlTypeCollectionEnabled([NotNull] string behavior, st
9774 private void CheckControlTypeCollectionEnabled (
9875 [ NotNull ] string behavior ,
9976 string enabled ,
100- [ NotNull ] Table table ,
101- [ NotNull ] Action < string > runnerAction )
77+ [ NotNull ] Table table )
10278 {
10379 foreach ( var row in table . Rows )
10480 {
81+ var runnerAction = _runnerService . GetRunner ( _scenarioContext ) ;
10582 var control = "the \" " + row . Values . First ( ) + "\" " + row . Values . Last ( ) ;
10683 runnerAction ( $ "{ control } { behavior } { enabled } ") ;
10784 }
0 commit comments