annotate Implab.Test/Mock/MockRunnableComponent.cs @ 229:5f7a3e1d32b9 v2

JsonXmlReader performance tuning JsonScanner now operates strings and doesn't parses number and literals. Added SerializationHelpers to common serialize/deserialize operations
author cin
date Tue, 12 Sep 2017 19:07:42 +0300
parents 7d07503621fe
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
203
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
1 using System;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
2 using Implab.Components;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
3
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
4 namespace Implab.Test.Mock {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
5 class MockRunnableComponent : RunnableComponent {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
6 public MockRunnableComponent(bool initialized) : base(initialized) {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
7 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
8
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
9 public MockRunnableComponent(bool initialized, bool reusable) : base(initialized, reusable) {
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
10 }
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
11
203
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
12 public Action MockInit {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
13 get;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
14 set;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
15 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
16
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
17 public Func<IPromise> MockStart {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
18 get;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
19 set;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
20 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
21
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
22 public Func<IPromise> MockStop {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
23 get;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
24 set;
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
25 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
26
208
7d07503621fe RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
cin
parents: 205
diff changeset
27 public Action<bool> MockDispose {
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
28 get;
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
29 set;
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
30 }
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
31
203
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
32 protected override IPromise OnStart() {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
33 return MockStart != null ? Safe.Run(MockStart).Chain(base.OnStart) : Safe.Run(base.OnStart);
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
34 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
35
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
36 protected override IPromise OnStop() {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
37 return MockStop != null ? Safe.Run(MockStop).Chain(base.OnStop) : Safe.Run(base.OnStop);
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
38 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
39
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
40 protected override void OnInitialize() {
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
41 if (MockInit != null)
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
42 MockInit();
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
43 }
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
44
208
7d07503621fe RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
cin
parents: 205
diff changeset
45 protected override void Dispose(bool disposing) {
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
46 if (MockDispose != null)
208
7d07503621fe RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
cin
parents: 205
diff changeset
47 MockDispose(disposing);
7d07503621fe RunnableComponent.Dispose(bool,Exception) changed to standart Dispose(bool)
cin
parents: 205
diff changeset
48 base.Dispose(disposing);
205
8200ab154c8a Added ResetState to RunnableComponent to reset in case of failure
cin
parents: 203
diff changeset
49 }
203
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
50 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
51 }
4d9830a9bbb8 Added 'Fail' method to RunnableComponent which allows component to move from
cin
parents:
diff changeset
52