@@ -142,22 +142,21 @@ await TestHostHelper.CreateCollectionRulesHost(_outputHelper, rootOptions =>
142
142
[ Fact ]
143
143
public async Task ProcessInfoTest ( )
144
144
{
145
- CollectionRuleActionOptions actionOptions = null ;
145
+ PassThroughOptions settings = null ;
146
146
await TestHostHelper . CreateCollectionRulesHost ( _outputHelper , rootOptions =>
147
147
{
148
148
CollectionRuleOptions options = rootOptions . CreateCollectionRule ( DefaultRuleName )
149
149
. AddPassThroughAction ( "a1" , ConfigurationTokenParser . ProcessNameReference , ConfigurationTokenParser . ProcessIdReference , ConfigurationTokenParser . CommandLineReference )
150
150
. SetStartupTrigger ( ) ;
151
151
152
- actionOptions = options . Actions . Last ( ) ;
152
+ settings = ( PassThroughOptions ) options . Actions . Last ( ) . Settings ;
153
153
} , host =>
154
154
{
155
155
using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource ( TimeoutMs ) ;
156
156
157
157
CollectionRuleOptions ruleOptions = host . Services . GetRequiredService < IOptionsMonitor < CollectionRuleOptions > > ( ) . Get ( DefaultRuleName ) ;
158
158
ILogger < CollectionRuleService > logger = host . Services . GetRequiredService < ILogger < CollectionRuleService > > ( ) ;
159
159
TimeProvider timeProvider = host . Services . GetRequiredService < TimeProvider > ( ) ;
160
- ICollectionRuleActionOperations actionOperations = host . Services . GetRequiredService < ICollectionRuleActionOperations > ( ) ;
161
160
162
161
const string processName = "actionProcess" ;
163
162
const int processId = 123 ;
@@ -166,8 +165,8 @@ await TestHostHelper.CreateCollectionRulesHost(_outputHelper, rootOptions =>
166
165
Guid instanceId = Guid . NewGuid ( ) ;
167
166
CollectionRuleContext context = new ( DefaultRuleName , ruleOptions , new TestProcessInfo ( instanceId , processId : processId , commandLine : commandLine ) , HostInfo . GetCurrent ( timeProvider ) , logger ) ;
168
167
169
- ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context , actionOperations ) ;
170
- PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , actionOptions ) ;
168
+ ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context ) ;
169
+ PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , settings ) ;
171
170
172
171
Assert . Equal ( processName , newSettings . Input1 ) ;
173
172
Assert . Equal ( processId . ToString ( CultureInfo . InvariantCulture ) , newSettings . Input2 ) ;
@@ -182,30 +181,29 @@ await TestHostHelper.CreateCollectionRulesHost(_outputHelper, rootOptions =>
182
181
[ Fact ]
183
182
public async Task HostInfoTest ( )
184
183
{
185
- CollectionRuleActionOptions actionOptions = null ;
184
+ PassThroughOptions settings = null ;
186
185
await TestHostHelper . CreateCollectionRulesHost ( _outputHelper , rootOptions =>
187
186
{
188
187
CollectionRuleOptions options = rootOptions . CreateCollectionRule ( DefaultRuleName )
189
188
. AddPassThroughAction ( "a1" , ConfigurationTokenParser . HostNameReference , ConfigurationTokenParser . UnixTimeReference , "test" )
190
189
. SetStartupTrigger ( ) ;
191
190
192
- actionOptions = options . Actions . Last ( ) ;
191
+ settings = ( PassThroughOptions ) options . Actions . Last ( ) . Settings ;
193
192
} , host =>
194
193
{
195
194
using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource ( TimeoutMs ) ;
196
195
197
196
CollectionRuleOptions ruleOptions = host . Services . GetRequiredService < IOptionsMonitor < CollectionRuleOptions > > ( ) . Get ( DefaultRuleName ) ;
198
197
ILogger < CollectionRuleService > logger = host . Services . GetRequiredService < ILogger < CollectionRuleService > > ( ) ;
199
198
MockTimeProvider timeProvider = host . Services . GetRequiredService < TimeProvider > ( ) as MockTimeProvider ;
200
- ICollectionRuleActionOperations actionOperations = host . Services . GetRequiredService < ICollectionRuleActionOperations > ( ) ;
201
199
202
200
const string hostName = "exampleHost" ;
203
201
Guid instanceId = Guid . NewGuid ( ) ;
204
202
HostInfo hostInfo = new HostInfo ( hostName , timeProvider ) ;
205
203
CollectionRuleContext context = new ( DefaultRuleName , ruleOptions , new TestProcessInfo ( instanceId ) , hostInfo , logger ) ;
206
204
207
- ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context , actionOperations ) ;
208
- PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , actionOptions ) ;
205
+ ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context ) ;
206
+ PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , settings ) ;
209
207
210
208
Assert . Equal ( hostName , newSettings . Input1 ) ;
211
209
Assert . Equal ( hostInfo . TimeProvider . GetUtcNow ( ) . ToUnixTimeSeconds ( ) . ToString ( CultureInfo . InvariantCulture ) , newSettings . Input2 ) ;
@@ -225,30 +223,29 @@ public async Task InvalidTokenReferenceTest()
225
223
string a2input3 = "$(Actions.a1.MissingResult)" ;
226
224
227
225
LogRecord record = new LogRecord ( ) ;
228
- CollectionRuleActionOptions actionOptions = null ;
226
+ PassThroughOptions settings = null ;
229
227
await TestHostHelper . CreateCollectionRulesHost ( _outputHelper , rootOptions =>
230
228
{
231
229
CollectionRuleOptions options = rootOptions . CreateCollectionRule ( DefaultRuleName )
232
230
. AddPassThroughAction ( "a1" , "a1input1" , "a1input2" , "a1input3" )
233
231
. AddPassThroughAction ( "a2" , a2input1 , a2input2 , a2input3 )
234
232
. SetStartupTrigger ( ) ;
235
233
236
- actionOptions = options . Actions . Last ( ) ;
234
+ settings = ( PassThroughOptions ) options . Actions . Last ( ) . Settings ;
237
235
} , host =>
238
236
{
239
237
using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource ( TimeoutMs ) ;
240
238
241
239
CollectionRuleOptions ruleOptions = host . Services . GetRequiredService < IOptionsMonitor < CollectionRuleOptions > > ( ) . Get ( DefaultRuleName ) ;
242
240
ILogger < CollectionRuleService > logger = host . Services . GetRequiredService < ILogger < CollectionRuleService > > ( ) ;
243
241
TimeProvider timeProvider = host . Services . GetRequiredService < TimeProvider > ( ) ;
244
- ICollectionRuleActionOperations actionOperations = host . Services . GetRequiredService < ICollectionRuleActionOperations > ( ) ;
245
242
246
243
Guid instanceId = Guid . NewGuid ( ) ;
247
244
CollectionRuleContext context = new ( DefaultRuleName , ruleOptions , new TestProcessInfo ( instanceId ) , HostInfo . GetCurrent ( timeProvider ) , logger ) ;
248
245
249
- ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context , actionOperations ) ;
246
+ ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context ) ;
250
247
analyzer . GetActionDependencies ( 1 ) ;
251
- analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , actionOptions ) ;
248
+ analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , settings ) ;
252
249
253
250
Assert . Equal ( 3 , record . Events . Count ) ;
254
251
Assert . Equal ( LoggingEventIds . InvalidActionReferenceToken . Id ( ) , record . Events [ 0 ] . EventId . Id ) ;
@@ -267,28 +264,27 @@ await TestHostHelper.CreateCollectionRulesHost(_outputHelper, rootOptions =>
267
264
[ Fact ]
268
265
public async Task RuntimeIdReferenceTest ( )
269
266
{
270
- CollectionRuleActionOptions actionOptions = null ;
267
+ PassThroughOptions settings = null ;
271
268
await TestHostHelper . CreateCollectionRulesHost ( _outputHelper , rootOptions =>
272
269
{
273
270
CollectionRuleOptions options = rootOptions . CreateCollectionRule ( DefaultRuleName )
274
271
. AddPassThroughAction ( "a1" , ConfigurationTokenParser . RuntimeIdReference , "test" , "test" )
275
272
. SetStartupTrigger ( ) ;
276
273
277
- actionOptions = options . Actions . Last ( ) ;
278
- } , host =>
274
+ settings = ( PassThroughOptions ) options . Actions . Last ( ) . Settings ;
275
+ } , host =>
279
276
{
280
277
using CancellationTokenSource cancellationTokenSource = new CancellationTokenSource ( TimeoutMs ) ;
281
278
282
279
CollectionRuleOptions ruleOptions = host . Services . GetRequiredService < IOptionsMonitor < CollectionRuleOptions > > ( ) . Get ( DefaultRuleName ) ;
283
280
ILogger < CollectionRuleService > logger = host . Services . GetRequiredService < ILogger < CollectionRuleService > > ( ) ;
284
281
TimeProvider timeProvider = host . Services . GetRequiredService < TimeProvider > ( ) ;
285
- ICollectionRuleActionOperations actionOperations = host . Services . GetRequiredService < ICollectionRuleActionOperations > ( ) ;
286
282
287
283
Guid instanceId = Guid . NewGuid ( ) ;
288
284
CollectionRuleContext context = new ( DefaultRuleName , ruleOptions , new TestProcessInfo ( instanceId ) , HostInfo . GetCurrent ( timeProvider ) , logger ) ;
289
285
290
- ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context , actionOperations ) ;
291
- PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , actionOptions ) ;
286
+ ActionOptionsDependencyAnalyzer analyzer = ActionOptionsDependencyAnalyzer . Create ( context ) ;
287
+ PassThroughOptions newSettings = ( PassThroughOptions ) analyzer . SubstituteOptionValues ( new Dictionary < string , CollectionRuleActionResult > ( ) , 1 , settings ) ;
292
288
293
289
Assert . Equal ( instanceId . ToString ( "D" ) , newSettings . Input1 ) ;
294
290
0 commit comments