comparison Implab.Test/Mock/MockRunnableComponent.cs @ 205:8200ab154c8a v2

Added ResetState to RunnableComponent to reset in case of failure Added StateChanged event to IRunnable Renamed Promise.SUCCESS -> Promise.Success Added Promise.FromException Renamed Bundle -> PromiseAll in PromiseExtensions
author cin
date Tue, 25 Oct 2016 17:40:33 +0300
parents 4d9830a9bbb8
children 7d07503621fe
comparison
equal deleted inserted replaced
203:4d9830a9bbb8 205:8200ab154c8a
2 using Implab.Components; 2 using Implab.Components;
3 3
4 namespace Implab.Test.Mock { 4 namespace Implab.Test.Mock {
5 class MockRunnableComponent : RunnableComponent { 5 class MockRunnableComponent : RunnableComponent {
6 public MockRunnableComponent(bool initialized) : base(initialized) { 6 public MockRunnableComponent(bool initialized) : base(initialized) {
7 }
8
9 public MockRunnableComponent(bool initialized, bool reusable) : base(initialized, reusable) {
7 } 10 }
8 11
9 public Action MockInit { 12 public Action MockInit {
10 get; 13 get;
11 set; 14 set;
19 public Func<IPromise> MockStop { 22 public Func<IPromise> MockStop {
20 get; 23 get;
21 set; 24 set;
22 } 25 }
23 26
27 public Action<bool, Exception> MockDispose {
28 get;
29 set;
30 }
31
24 protected override IPromise OnStart() { 32 protected override IPromise OnStart() {
25 return MockStart != null ? Safe.Run(MockStart).Chain(base.OnStart) : Safe.Run(base.OnStart); 33 return MockStart != null ? Safe.Run(MockStart).Chain(base.OnStart) : Safe.Run(base.OnStart);
26 } 34 }
27 35
28 protected override IPromise OnStop() { 36 protected override IPromise OnStop() {
31 39
32 protected override void OnInitialize() { 40 protected override void OnInitialize() {
33 if (MockInit != null) 41 if (MockInit != null)
34 MockInit(); 42 MockInit();
35 } 43 }
44
45 protected override void Dispose(bool disposing, Exception lastError) {
46 if (MockDispose != null)
47 MockDispose(disposing, lastError);
48 base.Dispose(disposing, lastError);
49 }
36 } 50 }
37 } 51 }
38 52