-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathSubFlows.cs
More file actions
73 lines (64 loc) · 2.13 KB
/
SubFlows.cs
File metadata and controls
73 lines (64 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.IO;
using Castle.Core.Logging;
using TestStack.White.Configuration;
namespace TestStack.White.Reporting.Domain
{
public class SubFlows : List<SubFlow>
{
private readonly string archiveLocation;
private readonly string flowName;
private int currentSubFlowIndex = -1;
private readonly ILogger logger = CoreConfigurationLocator.Get().LoggerFactory.Create(typeof(SubFlow));
public SubFlows(string archiveLocation, string flowName)
{
this.archiveLocation = archiveLocation;
this.flowName = flowName;
}
public virtual void Begin(string name)
{
Add(new SubFlow(name, flowName, archiveLocation));
currentSubFlowIndex++;
}
public virtual void Next(Type type)
{
if (IsEmpty())
{
var subFlow = new SubFlow(flowName + "[" + currentSubFlowIndex + "]", flowName, archiveLocation);
subFlow.Next(type);
Add(subFlow);
currentSubFlowIndex++;
return;
}
this[currentSubFlowIndex].Next(type);
}
public virtual void Act()
{
if (!IsEmpty())
this[currentSubFlowIndex].Act();
}
public virtual bool IsEmpty()
{
return Count == 0;
}
public virtual string FlowName
{
get { return flowName; }
}
public virtual void Finish()
{
ReportWriter.Write(this, archiveLocation);
FetchErrorReportIfExists();
}
private void FetchErrorReportIfExists()
{
string errorReport = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\ErrorReport.zip";
if (File.Exists(errorReport))
{
logger.Info("An Error has occurred in the application. Refer " + archiveLocation + @"\ErrorReport.zip" + " for details");
File.Move(errorReport, archiveLocation + @"\ErrorReport.zip");
}
}
}
}