@@ -5,84 +5,84 @@ public static class JsonConfigMapper
55 public static AtataContextBuilder Map < TConfig > ( TConfig config , AtataContextBuilder builder )
66 where TConfig : JsonConfig < TConfig >
77 {
8- if ( config . DriverInitializationStage != null )
8+ if ( config . DriverInitializationStage is not null )
99 builder . UseDriverInitializationStage ( config . DriverInitializationStage . Value ) ;
1010
11- if ( config . BaseUrl != null )
11+ if ( config . BaseUrl is not null )
1212 builder . UseBaseUrl ( config . BaseUrl ) ;
1313
14- if ( config . DefaultControlVisibility != null )
14+ if ( config . DefaultControlVisibility is not null )
1515 builder . UseDefaultControlVisibility ( config . DefaultControlVisibility . Value ) ;
1616
17- if ( config . Culture != null )
17+ if ( config . Culture is not null )
1818 builder . UseCulture ( config . Culture ) ;
1919
20- if ( config . TimeZone != null )
20+ if ( config . TimeZone is not null )
2121 builder . UseTimeZone ( config . TimeZone ) ;
2222
23- if ( config . ArtifactsPath != null )
23+ if ( config . ArtifactsPath is not null )
2424 builder . UseArtifactsPath ( config . ArtifactsPath ) ;
2525
26- if ( config . Variables != null )
26+ if ( config . Variables is not null )
2727 builder . AddVariables ( config . Variables ) ;
2828
29- if ( config . BaseRetryTimeout != null )
29+ if ( config . BaseRetryTimeout is not null )
3030 builder . UseBaseRetryTimeout ( TimeSpan . FromSeconds ( config . BaseRetryTimeout . Value ) ) ;
3131
32- if ( config . BaseRetryInterval != null )
32+ if ( config . BaseRetryInterval is not null )
3333 builder . UseBaseRetryInterval ( TimeSpan . FromSeconds ( config . BaseRetryInterval . Value ) ) ;
3434
35- if ( config . ElementFindTimeout != null )
35+ if ( config . ElementFindTimeout is not null )
3636 builder . UseElementFindTimeout ( TimeSpan . FromSeconds ( config . ElementFindTimeout . Value ) ) ;
3737
38- if ( config . ElementFindRetryInterval != null )
38+ if ( config . ElementFindRetryInterval is not null )
3939 builder . UseElementFindRetryInterval ( TimeSpan . FromSeconds ( config . ElementFindRetryInterval . Value ) ) ;
4040
41- if ( config . WaitingTimeout != null )
41+ if ( config . WaitingTimeout is not null )
4242 builder . UseWaitingTimeout ( TimeSpan . FromSeconds ( config . WaitingTimeout . Value ) ) ;
4343
44- if ( config . WaitingRetryInterval != null )
44+ if ( config . WaitingRetryInterval is not null )
4545 builder . UseWaitingRetryInterval ( TimeSpan . FromSeconds ( config . WaitingRetryInterval . Value ) ) ;
4646
47- if ( config . VerificationTimeout != null )
47+ if ( config . VerificationTimeout is not null )
4848 builder . UseVerificationTimeout ( TimeSpan . FromSeconds ( config . VerificationTimeout . Value ) ) ;
4949
50- if ( config . VerificationRetryInterval != null )
50+ if ( config . VerificationRetryInterval is not null )
5151 builder . UseVerificationRetryInterval ( TimeSpan . FromSeconds ( config . VerificationRetryInterval . Value ) ) ;
5252
53- if ( config . DefaultAssemblyNamePatternToFindTypes != null )
53+ if ( config . DefaultAssemblyNamePatternToFindTypes is not null )
5454 builder . UseDefaultAssemblyNamePatternToFindTypes ( config . DefaultAssemblyNamePatternToFindTypes ) ;
5555
56- if ( config . AssemblyNamePatternToFindComponentTypes != null )
56+ if ( config . AssemblyNamePatternToFindComponentTypes is not null )
5757 builder . UseAssemblyNamePatternToFindComponentTypes ( config . AssemblyNamePatternToFindComponentTypes ) ;
5858
59- if ( config . AssemblyNamePatternToFindAttributeTypes != null )
59+ if ( config . AssemblyNamePatternToFindAttributeTypes is not null )
6060 builder . UseAssemblyNamePatternToFindAttributeTypes ( config . AssemblyNamePatternToFindAttributeTypes ) ;
6161
62- if ( config . AssemblyNamePatternToFindEventTypes != null )
62+ if ( config . AssemblyNamePatternToFindEventTypes is not null )
6363 builder . UseAssemblyNamePatternToFindEventTypes ( config . AssemblyNamePatternToFindEventTypes ) ;
6464
65- if ( config . AssemblyNamePatternToFindEventHandlerTypes != null )
65+ if ( config . AssemblyNamePatternToFindEventHandlerTypes is not null )
6666 builder . UseAssemblyNamePatternToFindEventHandlerTypes ( config . AssemblyNamePatternToFindEventHandlerTypes ) ;
6767
6868 Lazy < Assembly [ ] > lazyAssembliesToFindTypesIn = new Lazy < Assembly [ ] > (
6969 ( ) => AssemblyFinder . FindAllByPattern ( builder . BuildingContext . DefaultAssemblyNamePatternToFindTypes ) ,
7070 isThreadSafe : false ) ;
7171
72- if ( config . AssertionExceptionType != null )
72+ if ( config . AssertionExceptionType is not null )
7373 builder . UseAssertionExceptionType (
7474 TypeFinder . FindInAssemblies ( config . AssertionExceptionType , lazyAssembliesToFindTypesIn . Value ) ) ;
7575
76- if ( config . AggregateAssertionExceptionType != null )
76+ if ( config . AggregateAssertionExceptionType is not null )
7777 builder . UseAggregateAssertionExceptionType (
7878 TypeFinder . FindInAssemblies ( config . AggregateAssertionExceptionType , lazyAssembliesToFindTypesIn . Value ) ) ;
7979
80- if ( config . AggregateAssertionStrategyType != null )
80+ if ( config . AggregateAssertionStrategyType is not null )
8181 builder . UseAggregateAssertionStrategy (
8282 ActivatorEx . CreateInstance < IAggregateAssertionStrategy > (
8383 TypeFinder . FindInAssemblies ( config . AggregateAssertionStrategyType , lazyAssembliesToFindTypesIn . Value ) ) ) ;
8484
85- if ( config . WarningReportStrategyType != null )
85+ if ( config . WarningReportStrategyType is not null )
8686 builder . UseWarningReportStrategy (
8787 ActivatorEx . CreateInstance < IWarningReportStrategy > (
8888 TypeFinder . FindInAssemblies ( config . WarningReportStrategyType , lazyAssembliesToFindTypesIn . Value ) ) ) ;
@@ -101,15 +101,17 @@ public static AtataContextBuilder Map<TConfig>(TConfig config, AtataContextBuild
101101
102102 if ( config . TakeScreenshotOnNUnitError )
103103 {
104- if ( config . TakeScreenshotOnNUnitErrorTitle != null )
105- builder . TakeScreenshotOnNUnitError ( config . TakeScreenshotOnNUnitErrorTitle ) ;
104+ ScreenshotKind screenshotKind = config . TakeScreenshotOnNUnitErrorKind ?? ScreenshotKind . Default ;
105+
106+ if ( config . TakeScreenshotOnNUnitErrorTitle is not null )
107+ builder . TakeScreenshotOnNUnitError ( screenshotKind , config . TakeScreenshotOnNUnitErrorTitle ) ;
106108 else
107- builder . TakeScreenshotOnNUnitError ( ) ;
109+ builder . TakeScreenshotOnNUnitError ( screenshotKind ) ;
108110 }
109111
110112 if ( config . TakePageSnapshotOnNUnitError )
111113 {
112- if ( config . TakePageSnapshotOnNUnitErrorTitle != null )
114+ if ( config . TakePageSnapshotOnNUnitErrorTitle is not null )
113115 builder . TakePageSnapshotOnNUnitError ( config . TakePageSnapshotOnNUnitErrorTitle ) ;
114116 else
115117 builder . TakePageSnapshotOnNUnitError ( ) ;
@@ -118,7 +120,7 @@ public static AtataContextBuilder Map<TConfig>(TConfig config, AtataContextBuild
118120 if ( config . OnCleanUpAddArtifactsToNUnitTestContext )
119121 builder . OnCleanUpAddArtifactsToNUnitTestContext ( ) ;
120122
121- if ( config . OnCleanUpAddDirectoryFilesToNUnitTestContext != null )
123+ if ( config . OnCleanUpAddDirectoryFilesToNUnitTestContext is not null )
122124 builder . OnCleanUpAddDirectoryFilesToNUnitTestContext ( config . OnCleanUpAddDirectoryFilesToNUnitTestContext ) ;
123125
124126 if ( config . UseNUnitAggregateAssertionStrategy )
@@ -130,31 +132,34 @@ public static AtataContextBuilder Map<TConfig>(TConfig config, AtataContextBuild
130132 if ( config . UseAllNUnitFeatures )
131133 builder . UseAllNUnitFeatures ( ) ;
132134
133- if ( config . LogConsumers != null )
135+ if ( config . LogConsumers is not null )
134136 {
135137 foreach ( var item in config . LogConsumers )
136138 MapLogConsumer ( item , builder ) ;
137139 }
138140
139- if ( config . ScreenshotConsumers != null )
141+ if ( config . ScreenshotConsumers is not null )
140142 {
141143 foreach ( var item in config . ScreenshotConsumers )
142144 MapScreenshotConsumer ( item , builder ) ;
143145 }
144146
145- if ( config . Drivers != null )
147+ if ( config . Drivers is not null )
146148 {
147149 foreach ( var item in config . Drivers )
148150 MapDriver ( item , builder ) ;
149151 }
150152
151- if ( config . Attributes != null )
153+ if ( config . Attributes is not null )
152154 MapAttributes ( config . Attributes , builder ) ;
153155
154- if ( config . EventSubscriptions != null )
156+ if ( config . EventSubscriptions is not null )
155157 MapEventSubscriptions ( config . EventSubscriptions , builder ) ;
156158
157- if ( config . PageSnapshots != null )
159+ if ( config . Screenshots is not null )
160+ MapScreenshots ( config . Screenshots , builder ) ;
161+
162+ if ( config . PageSnapshots is not null )
158163 MapPageSnapshots ( config . PageSnapshots , builder ) ;
159164
160165 return builder ;
@@ -282,6 +287,20 @@ private static void MapEventSubscriptions(List<EventSubscriptionJsonSection> sec
282287 sections . Select ( x => eventSubscriptionMapper . Map ( x ) ) ) ;
283288 }
284289
290+ private static void MapScreenshots ( ScreenshotsJsonSection section , AtataContextBuilder builder )
291+ {
292+ if ( section ? . Strategy ? . Type != null )
293+ {
294+ if ( ! ScreenshotStrategyAliases . TryResolve ( section . Strategy . Type , out IScreenshotStrategy strategy ) )
295+ strategy = ( IScreenshotStrategy ) CreateObject (
296+ section . Strategy . Type ,
297+ section . Strategy . ExtraPropertiesMap ,
298+ builder . BuildingContext . DefaultAssemblyNamePatternToFindTypes ) ;
299+
300+ builder . Screenshots . UseStrategy ( strategy ) ;
301+ }
302+ }
303+
285304 private static void MapPageSnapshots ( PageSnapshotsJsonSection section , AtataContextBuilder builder )
286305 {
287306 if ( ! string . IsNullOrEmpty ( section . FileNameTemplate ) )
0 commit comments