-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathServiceControlAddScreenLoadedTests.cs
281 lines (228 loc) · 10.8 KB
/
ServiceControlAddScreenLoadedTests.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
namespace ServiceControl.Config.Tests
{
using System;
using System.ComponentModel;
using NUnit.Framework;
using ServiceControlInstaller.Engine.Configuration.ServiceControl;
using UI.InstanceAdd;
using Xaml.Controls;
class AddErrorInstanceScreenLoadedTests
{
static readonly string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
static readonly string programX86Path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
[Test]
public void Error_and_Audit_Instances_are_selected_for_install()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.InstallErrorInstance, Is.True);
Assert.That(viewModel.InstallAuditInstance, Is.True);
});
}
[Test]
public void Transports_are_populated()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.Transports, Is.Not.Empty);
Assert.That(viewModel.SelectedTransport, Is.Null);
});
}
[Test]
public void Transport_connection_string_is_null()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ShowConnectionString, Is.False);
Assert.That(viewModel.ConnectionString, Is.Null);
Assert.That(viewModel.SampleConnectionString, Is.Null);
});
}
[Test]
public void ErrorForwardingOptions_are_populated()
{
var viewModel = new ServiceControlAddViewModel();
Assert.That(viewModel.ErrorForwardingOptions, Is.Not.Empty);
}
[Test]
public void FullTextSearchOptions_are_populated()
{
var viewModel = new ServiceControlAddViewModel();
Assert.That(viewModel.ErrorEnableFullTextSearchOnBodiesOptions, Is.Not.Empty);
}
[Test]
public void User_account_is_set_to_local_system()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorServiceAccount, Is.EqualTo("LocalSystem"));
Assert.That(viewModel.ErrorUseSystemAccount, Is.True);
Assert.That(viewModel.ErrorUseServiceAccount, Is.False);
Assert.That(viewModel.ErrorUseProvidedAccount, Is.False);
Assert.That(viewModel.ErrorPasswordEnabled, Is.False);
Assert.That(viewModel.ErrorPassword, Is.Empty);
});
Assert.Multiple(() =>
{
Assert.That(viewModel.AuditServiceAccount, Is.EqualTo("LocalSystem"));
Assert.That(viewModel.AuditUseSystemAccount, Is.True);
Assert.That(viewModel.AuditUseServiceAccount, Is.False);
Assert.That(viewModel.AuditUseProvidedAccount, Is.False);
Assert.That(viewModel.AuditPasswordEnabled, Is.False);
Assert.That(viewModel.AuditPassword, Is.Empty);
});
}
[Test]
public void Hostname_is_local_host()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorHostName, Is.EqualTo("localhost"));
Assert.That(viewModel.ErrorHostNameWarning, Is.Empty);
Assert.That(viewModel.AuditHostName, Is.EqualTo("localhost"));
Assert.That(viewModel.AuditHostNameWarning, Is.Empty);
});
}
[Test]
public void Port_number_are_set_to_defaults_with_no_validation_errors()
{
var viewModel = new ServiceControlAddViewModel();
Assert.That(viewModel.ErrorPortNumber, Is.EqualTo("33333"));
var errorInfo = (INotifyDataErrorInfo)viewModel;
var errorPortNumberErrors = errorInfo.GetErrors(nameof(viewModel.ErrorPortNumber));
Assert.Multiple(() =>
{
Assert.That(errorPortNumberErrors, Is.Empty);
Assert.That(viewModel.AuditPortNumber, Is.EqualTo("44444"));
});
var auditPortNumberErrors = errorInfo.GetErrors(nameof(viewModel.AuditPortNumber));
Assert.That(auditPortNumberErrors, Is.Empty);
}
[Test]
public void Database_maintenance_port_number_are_set_to_defaults_with_no_validation_errors()
{
var viewModel = new ServiceControlAddViewModel();
Assert.That(viewModel.ErrorDatabaseMaintenancePortNumber, Is.EqualTo("33334"));
var errorInfo = (INotifyDataErrorInfo)viewModel;
var errorPortNumberErrors = errorInfo.GetErrors(nameof(viewModel.ErrorDatabaseMaintenancePortNumber));
Assert.Multiple(() =>
{
Assert.That(errorPortNumberErrors, Is.Empty);
Assert.That(viewModel.AuditDatabaseMaintenancePortNumber, Is.EqualTo("44445"));
});
var auditPortNumberErrors = errorInfo.GetErrors(nameof(viewModel.AuditDatabaseMaintenancePortNumber));
Assert.That(auditPortNumberErrors, Is.Empty);
}
[Test]
public void Destination_path_is_null()
{
var viewModel = new ServiceControlAddViewModel();
var errorInfo = (INotifyDataErrorInfo)viewModel;
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorDestinationPath, Is.EqualTo($@"{programX86Path}\Particular Software\Particular.ServiceControl"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.ErrorDestinationPath)), Is.Empty);
Assert.That(viewModel.AuditDestinationPath, Is.EqualTo($@"{programX86Path}\Particular Software\Particular.ServiceControl.Audit"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.AuditDestinationPath)), Is.Empty);
});
}
[Test]
public void Log_path_is_null()
{
var viewModel = new ServiceControlAddViewModel();
var errorInfo = (INotifyDataErrorInfo)viewModel;
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorLogPath, Is.EqualTo($@"{programDataPath}\Particular\ServiceControl\Particular.ServiceControl\Logs"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.ErrorLogPath)), Is.Empty);
Assert.That(viewModel.AuditLogPath, Is.EqualTo($@"{programDataPath}\Particular\ServiceControl\Particular.ServiceControl.Audit\Logs"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.AuditLogPath)), Is.Empty);
});
}
[Test]
public void Database_path_is_null()
{
var viewModel = new ServiceControlAddViewModel();
var errorInfo = (INotifyDataErrorInfo)viewModel;
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorDatabasePath, Is.EqualTo($@"{programDataPath}\Particular\ServiceControl\Particular.ServiceControl\DB"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.ErrorDatabasePath)), Is.Empty);
Assert.That(viewModel.AuditDatabasePath, Is.EqualTo($@"{programDataPath}\Particular\ServiceControl\Particular.ServiceControl.Audit\DB"));
Assert.That(errorInfo.GetErrors(nameof(viewModel.AuditDatabasePath)), Is.Empty);
});
}
[Test]
public void Retention_Period_is_set_to_default_days()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorRetentionUnits, Is.EqualTo(TimeSpanUnits.Days));
Assert.That(viewModel.ErrorRetention, Is.EqualTo(SettingConstants.ErrorRetentionPeriodDefaultInDaysForUI));
Assert.That(viewModel.ErrorRetention, Is.GreaterThanOrEqualTo(viewModel.MinimumErrorRetentionPeriod));
Assert.That(viewModel.ErrorRetention, Is.LessThanOrEqualTo(viewModel.MaximumErrorRetentionPeriod));
});
Assert.Multiple(() =>
{
Assert.That(viewModel.AuditRetentionUnits, Is.EqualTo(TimeSpanUnits.Days));
Assert.That(viewModel.AuditRetention, Is.EqualTo(SettingConstants.AuditRetentionPeriodDefaultInDaysForUI));
Assert.That(viewModel.AuditRetention, Is.GreaterThanOrEqualTo(viewModel.MinimumErrorRetentionPeriod));
Assert.That(viewModel.AuditRetention, Is.LessThanOrEqualTo(viewModel.MaximumErrorRetentionPeriod));
});
}
[Test]
public void Error_queue_name_has_default_value()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorQueueName, Is.Not.Empty);
Assert.That(viewModel.ErrorQueueName, Is.EqualTo("error"));
});
Assert.Multiple(() =>
{
Assert.That(viewModel.AuditQueueName, Is.Not.Empty);
Assert.That(viewModel.AuditQueueName, Is.EqualTo("audit"));
});
}
[Test]
public void Error_Forwarding_is_disabled()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorForwardingOptions, Is.Not.Empty);
Assert.That(viewModel.ErrorForwarding.Value, Is.EqualTo(false));
Assert.That(viewModel.ErrorForwardingQueueName, Is.Null);
Assert.That(viewModel.ShowErrorForwardingQueue, Is.False);
});
Assert.Multiple(() =>
{
Assert.That(viewModel.AuditForwardingOptions, Is.Not.Empty);
Assert.That(viewModel.AuditForwarding.Value, Is.EqualTo(false));
Assert.That(viewModel.ShowAuditForwardingQueue, Is.False);
});
}
[Test]
public void Full_text_search_on_bodies_is_enabled()
{
var viewModel = new ServiceControlAddViewModel();
Assert.Multiple(() =>
{
Assert.That(viewModel.ErrorEnableFullTextSearchOnBodiesOptions, Is.Not.Empty);
Assert.That(viewModel.ErrorEnableFullTextSearchOnBodies.Value, Is.EqualTo(true));
});
Assert.Multiple(() =>
{
Assert.That(viewModel.AuditEnableFullTextSearchOnBodiesOptions, Is.Not.Empty);
Assert.That(viewModel.AuditEnableFullTextSearchOnBodies.Value, Is.EqualTo(true));
});
}
}
}