forked from Inedo/bmx-nunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NUnitActionEditor.cs
166 lines (151 loc) · 6.83 KB
/
NUnitActionEditor.cs
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System.Linq;
using System.Globalization;
using System.Web.UI.WebControls;
using Inedo.BuildMaster.Data;
using Inedo.BuildMaster.Extensibility.Actions;
using Inedo.BuildMaster.Web.Controls;
using Inedo.BuildMaster.Web.Controls.Extensions;
using Inedo.Web.Controls;
namespace Inedo.BuildMasterExtensions.NUnit
{
/// <summary>
/// Custom editor for the NUnit action.
/// </summary>
internal sealed class NUnitActionEditor : ActionEditorBase
{
private SourceControlFileFolderPicker txtExePath;
private ValidatingTextBox txtTestFile, txtGroupName;
private DropDownList ddlFrameworkVersion;
private ValidatingTextBox txtAdditionalArguments;
private ValidatingTextBox txtCustomXmlOutputPath;
private CheckBox chkTreatInconclusiveTestsAsFailure;
/// <summary>
/// Initializes a new instance of the <see cref="NUnitActionEditor"/> class.
/// </summary>
public NUnitActionEditor()
{
}
/// <summary>
/// Gets a value indicating whether a textbox to edit the source directory should be displayed.
/// </summary>
/// <value>
/// <c>true</c> if a textbox to edit the source directory should be displayed; otherwise, <c>false</c>.
/// </value>
public override bool DisplaySourceDirectory { get { return true; } }
protected override void CreateChildControls()
{
Tables.Deployables_Extended deployable = null;
if (this.DeployableId > 0) deployable = StoredProcs
.Applications_GetDeployable(this.DeployableId)
.Execute()
.FirstOrDefault();
this.txtExePath = new SourceControlFileFolderPicker
{
DisplayMode = SourceControlBrowser.DisplayModes.FoldersAndFiles,
ServerId = this.ServerId,
DefaultText = "Default for Selected Configuration"
};
this.txtGroupName = new ValidatingTextBox
{
Text = deployable != null ? deployable.Deployable_Name : string.Empty,
Width= 300,
Required = true
};
this.txtTestFile = new ValidatingTextBox
{
Required = true,
Width = 300
};
this.ddlFrameworkVersion = new DropDownList();
this.ddlFrameworkVersion.Items.Add(new ListItem("2.0.50727", "2.0.50727"));
this.ddlFrameworkVersion.Items.Add(new ListItem("4.0.30319", "4.0.30319"));
this.ddlFrameworkVersion.Items.Add(new ListItem("unspecified", ""));
this.ddlFrameworkVersion.SelectedValue = "";
this.txtAdditionalArguments = new ValidatingTextBox
{
Required = false,
Width = 300
};
this.txtCustomXmlOutputPath = new ValidatingTextBox
{
Required = false,
Width = 300,
DefaultText = "Managed by BuildMaster"
};
this.chkTreatInconclusiveTestsAsFailure = new CheckBox
{
Text = "Treat Inconclusive Tests as Failures",
Checked = true
};
this.Controls.Add(
new FormFieldGroup(
"Custom NUnit Executable Path",
"The path to (and including) nunit-console.exe if using a different version of NUnit than the one specified "
+"in the NUnit extension configuration.",
false,
new StandardFormField("NUnit Exe Path:", this.txtExePath)
),
new FormFieldGroup(
".NET Framework Version",
"The version of .NET which will host the unit test runner.",
false,
new StandardFormField(".NET Framework Version:", this.ddlFrameworkVersion)
),
new FormFieldGroup(
"Test File",
"The path relative to the source directory of the DLL, project file, or NUnit file to test against.",
false,
new StandardFormField("Test File:", this.txtTestFile)
),
new FormFieldGroup(
"Custom XML Output Path",
"The path relative to the source directory of the NUnit-generated XML output file.",
false,
new StandardFormField("XML Output Path:", this.txtCustomXmlOutputPath)
),
new FormFieldGroup(
"NUnit Options",
"Specify any additional options for NUnit here.",
false,
new StandardFormField("", this.chkTreatInconclusiveTestsAsFailure)
),
new FormFieldGroup(
"Group Name",
"The Group name allows you to easily identify the unit test.",
false,
new StandardFormField("Group Name:", this.txtGroupName)
),
new FormFieldGroup(
"Additional Arguments",
"The additional arguments to pass to the NUnit executable.",
true,
new StandardFormField("Additional Arguments:", this.txtAdditionalArguments)
)
);
}
public override void BindToForm(ActionBase extension)
{
var nunitAction = (NUnitAppAction)extension;
this.txtExePath.Text = nunitAction.ExePath;
this.txtTestFile.Text = nunitAction.TestFile;
this.txtGroupName.Text = nunitAction.GroupName;
this.ddlFrameworkVersion.SelectedValue = nunitAction.FrameworkVersion ?? "";
this.txtAdditionalArguments.Text = nunitAction.AdditionalArguments;
this.txtCustomXmlOutputPath.Text = nunitAction.CustomXmlOutputPath;
this.chkTreatInconclusiveTestsAsFailure.Checked = nunitAction.TreatInconclusiveAsFailure;
}
public override ActionBase CreateFromForm()
{
return new NUnitAppAction
{
ExePath = this.txtExePath.Text,
TestFile = this.txtTestFile.Text,
GroupName = this.txtGroupName.Text,
FrameworkVersion = this.ddlFrameworkVersion.SelectedValue,
AdditionalArguments = this.txtAdditionalArguments.Text,
CustomXmlOutputPath = this.txtCustomXmlOutputPath.Text,
TreatInconclusiveAsFailure = this.chkTreatInconclusiveTestsAsFailure.Checked
};
}
}
}