Mercurial > pub > ImplabNet
comparison Implab.Test/Mock/MockRunnableComponent.cs @ 203:4d9830a9bbb8 v2
Added 'Fail' method to RunnableComponent which allows component to move from
Running to Failed state.
Added PollingComponent a timer based runnable component
More tests
Added FailPromise a thin class to wrap exceptions
Fixed error handling in SuccessPromise classes.
| author | cin |
|---|---|
| date | Tue, 18 Oct 2016 17:49:54 +0300 |
| parents | |
| children | 8200ab154c8a |
comparison
equal
deleted
inserted
replaced
| 202:2651cb9a4250 | 203:4d9830a9bbb8 |
|---|---|
| 1 using System; | |
| 2 using Implab.Components; | |
| 3 | |
| 4 namespace Implab.Test.Mock { | |
| 5 class MockRunnableComponent : RunnableComponent { | |
| 6 public MockRunnableComponent(bool initialized) : base(initialized) { | |
| 7 } | |
| 8 | |
| 9 public Action MockInit { | |
| 10 get; | |
| 11 set; | |
| 12 } | |
| 13 | |
| 14 public Func<IPromise> MockStart { | |
| 15 get; | |
| 16 set; | |
| 17 } | |
| 18 | |
| 19 public Func<IPromise> MockStop { | |
| 20 get; | |
| 21 set; | |
| 22 } | |
| 23 | |
| 24 protected override IPromise OnStart() { | |
| 25 return MockStart != null ? Safe.Run(MockStart).Chain(base.OnStart) : Safe.Run(base.OnStart); | |
| 26 } | |
| 27 | |
| 28 protected override IPromise OnStop() { | |
| 29 return MockStop != null ? Safe.Run(MockStop).Chain(base.OnStop) : Safe.Run(base.OnStop); | |
| 30 } | |
| 31 | |
| 32 protected override void OnInitialize() { | |
| 33 if (MockInit != null) | |
| 34 MockInit(); | |
| 35 } | |
| 36 } | |
| 37 } | |
| 38 |
