6
6
using System . Linq ;
7
7
using System . Text ;
8
8
using System . Text . RegularExpressions ;
9
- using System . Xml ;
10
9
using System . Xml . Serialization ;
11
- using System . Xml . Xsl ;
12
10
using TechTalk . SpecFlow . Generator . Configuration ;
13
11
using TechTalk . SpecFlow . Parser . SyntaxElements ;
14
12
using TechTalk . SpecFlow . Reporting . StepDefinitionReport . ReportElements ;
@@ -17,42 +15,33 @@ namespace TechTalk.SpecFlow.Reporting.StepDefinitionReport
17
15
{
18
16
public class StepDefinitionReportGenerator
19
17
{
18
+ public StepDefinitionReportParameters ReportParameters { get ; set ; }
20
19
private readonly SpecFlowProject specFlowProject ;
21
20
private readonly List < BindingInfo > bindings ;
22
21
private readonly List < Feature > parsedFeatures ;
23
- private readonly bool showBindingsWithoutInsance ;
24
22
25
23
private ReportElements . StepDefinitionReport report ;
26
24
private Dictionary < BindingInfo , StepDefinition > stepDefByBinding ;
27
25
private Dictionary < StepDefinition , BindingInfo > bindingByStepDef ;
28
26
private readonly List < StepDefinition > stepDefsWithNoBinding = new List < StepDefinition > ( ) ;
29
27
30
- public StepDefinitionReportGenerator ( string projectFile , string binFolder , bool showBindingsWithoutInsance )
28
+ public StepDefinitionReportGenerator ( StepDefinitionReportParameters reportParameters )
31
29
{
32
- specFlowProject = MsBuildProjectReader . LoadSpecFlowProjectFromMsBuild ( projectFile ) ;
30
+ ReportParameters = reportParameters ;
33
31
32
+ specFlowProject = MsBuildProjectReader . LoadSpecFlowProjectFromMsBuild ( reportParameters . ProjectFile ) ;
34
33
parsedFeatures = ParserHelper . GetParsedFeatures ( specFlowProject ) ;
35
34
36
- var basePath = Path . Combine ( specFlowProject . ProjectFolder , binFolder ) ;
35
+ var basePath = Path . Combine ( specFlowProject . ProjectFolder , reportParameters . BinFolder ) ;
37
36
bindings = BindingCollector . CollectBindings ( specFlowProject , basePath ) ;
38
-
39
- this . showBindingsWithoutInsance = showBindingsWithoutInsance ;
40
- }
41
-
42
- public StepDefinitionReportGenerator ( SpecFlowProject specFlowProject , List < BindingInfo > bindings , List < Feature > parsedFeatures , bool showBindingsWithoutInsance )
43
- {
44
- this . specFlowProject = specFlowProject ;
45
- this . showBindingsWithoutInsance = showBindingsWithoutInsance ;
46
- this . bindings = bindings ;
47
- this . parsedFeatures = parsedFeatures ;
48
37
}
49
38
50
39
public ReportElements . StepDefinitionReport GenerateReport ( )
51
40
{
52
41
report = new ReportElements . StepDefinitionReport ( ) ;
53
42
report . ProjectName = specFlowProject . ProjectName ;
54
43
report . GeneratedAt = DateTime . Now . ToString ( "g" , CultureInfo . InvariantCulture ) ;
55
- report . ShowBindingsWithoutInsance = showBindingsWithoutInsance ;
44
+ report . ShowBindingsWithoutInsance = ReportParameters . ShowBindingsWithoutInsance ;
56
45
57
46
stepDefByBinding = new Dictionary < BindingInfo , StepDefinition > ( ) ;
58
47
bindingByStepDef = new Dictionary < StepDefinition , BindingInfo > ( ) ;
@@ -215,17 +204,17 @@ private string GetSampleText(BindingInfo bindingInfo)
215
204
return sampleText ;
216
205
}
217
206
218
- public void TransformReport ( string outputFilePath , string xsltFile )
207
+ public void TransformReport ( )
219
208
{
220
209
XmlSerializer serializer = new XmlSerializer ( typeof ( ReportElements . StepDefinitionReport ) , ReportElements . StepDefinitionReport . XmlNamespace ) ;
221
210
222
- if ( XsltHelper . IsXmlOutput ( outputFilePath ) )
211
+ if ( XsltHelper . IsXmlOutput ( ReportParameters . OutputFile ) )
223
212
{
224
- XsltHelper . TransformXml ( serializer , report , outputFilePath ) ;
213
+ XsltHelper . TransformXml ( serializer , report , ReportParameters . OutputFile ) ;
225
214
}
226
215
else
227
216
{
228
- XsltHelper . TransformHtml ( serializer , report , GetType ( ) , outputFilePath , specFlowProject . GeneratorConfiguration , xsltFile ) ;
217
+ XsltHelper . TransformHtml ( serializer , report , GetType ( ) , ReportParameters . OutputFile , specFlowProject . GeneratorConfiguration , ReportParameters . XsltFile ) ;
229
218
}
230
219
}
231
220
@@ -355,5 +344,12 @@ private ScenarioStep CloneTo(ScenarioStep step, string currentBlock)
355
344
newStep . TableArg = Clone ( step . TableArg ) ;
356
345
return newStep ;
357
346
}
347
+
348
+
349
+ public void GenerateAndTransformReport ( )
350
+ {
351
+ GenerateReport ( ) ;
352
+ TransformReport ( ) ;
353
+ }
358
354
}
359
355
}
0 commit comments