259
|
1 using System;
|
|
2 using System.Threading;
|
|
3 using System.Threading.Tasks;
|
|
4 using Implab.Components;
|
|
5 using Xunit;
|
|
6
|
260
|
7 namespace Implab.Test {
|
259
|
8
|
260
|
9 public class RunnableComponentTests {
|
259
|
10 [Fact]
|
260
|
11 public async Task Test1() {
|
259
|
12
|
260
|
13 using (var m = new MockPollComponent(true)) {
|
|
14 m.StartWorker = async (ct) => await Task.Yield();
|
|
15 m.StopWorker = async (ct) => await Task.Yield();
|
259
|
16
|
260
|
17 Assert.Equal(ExecutionState.Ready, m.State);
|
|
18 Assert.NotNull(m.Completion);
|
259
|
19
|
260
|
20 m.Start(CancellationToken.None);
|
|
21 await m.Completion;
|
|
22 Assert.Equal(ExecutionState.Running, m.State);
|
259
|
23
|
260
|
24 m.Stop(CancellationToken.None);
|
|
25 await m.Completion;
|
|
26 Assert.Equal(ExecutionState.Stopped, m.State);
|
259
|
27 }
|
|
28 }
|
|
29 }
|
|
30 }
|