using System; using System.Threading; using System.Threading.Tasks; using Implab.Components; using Xunit; namespace Implab.Test { public class RunnableComponentTests { [Fact] public async Task Test1() { using (var m = new MockPollComponent(true)) { m.StartWorker = async (ct) => await Task.Yield(); m.StopWorker = async (ct) => await Task.Yield(); Assert.Equal(ExecutionState.Ready, m.State); Assert.NotNull(m.Completion); m.Start(CancellationToken.None); await m.Completion; Assert.Equal(ExecutionState.Running, m.State); m.Stop(CancellationToken.None); await m.Completion; Assert.Equal(ExecutionState.Stopped, m.State); } } } }