diff Implab.Test/MockPollComponent.cs @ 260:547a2fc0d93e v3 v3.0.6

minor fixes
author cin
date Fri, 13 Apr 2018 19:14:59 +0300
parents
children f1696cdc3d7a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab.Test/MockPollComponent.cs	Fri Apr 13 19:14:59 2018 +0300
@@ -0,0 +1,35 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Implab.Components;
+
+namespace Implab.Test {
+    public class MockPollComponent : PollingComponent {
+
+        public Func<CancellationToken,Task> PollWorker { get; set;}
+
+        public Func<CancellationToken, Task> StartWorker { get; set; }
+
+        public Func<CancellationToken, Task> StopWorker { get; set; }
+
+        public MockPollComponent(bool initialized) : base(initialized) {
+        }
+
+        protected async override Task Poll(CancellationToken ct) {
+            if(PollWorker!= null)
+                await PollWorker.Invoke(ct);
+        }
+
+        protected async override Task StopInternalAsync(CancellationToken ct) {
+            if (StopWorker != null)
+                await StopWorker.Invoke(ct);
+        }
+
+        protected async override Task StartInternalAsync(CancellationToken ct) {
+            if (StartWorker != null)
+                await StartWorker.Invoke(ct);
+        }
+
+
+    }
+}
\ No newline at end of file