260
|
1 using System;
|
|
2 using System.Threading;
|
|
3 using System.Threading.Tasks;
|
|
4 using Implab.Components;
|
|
5
|
|
6 namespace Implab.Test {
|
|
7 public class MockPollComponent : PollingComponent {
|
|
8
|
|
9 public Func<CancellationToken,Task> PollWorker { get; set;}
|
|
10
|
|
11 public Func<CancellationToken, Task> StartWorker { get; set; }
|
|
12
|
|
13 public Func<CancellationToken, Task> StopWorker { get; set; }
|
|
14
|
|
15 public MockPollComponent(bool initialized) : base(initialized) {
|
|
16 }
|
|
17
|
|
18 protected async override Task Poll(CancellationToken ct) {
|
|
19 if(PollWorker!= null)
|
|
20 await PollWorker.Invoke(ct);
|
|
21 }
|
|
22
|
|
23 protected async override Task StopInternalAsync(CancellationToken ct) {
|
|
24 if (StopWorker != null)
|
|
25 await StopWorker.Invoke(ct);
|
|
26 }
|
|
27
|
|
28 protected async override Task StartInternalAsync(CancellationToken ct) {
|
|
29 if (StartWorker != null)
|
|
30 await StartWorker.Invoke(ct);
|
|
31 }
|
|
32
|
|
33
|
|
34 }
|
|
35 } |