##// END OF EJS Templates
added Safe.DispatchEvent() a legacy equivalent for '?.Invoke()'...
added Safe.DispatchEvent() a legacy equivalent for '?.Invoke()' added Safe.Dispose(IEnumerable) added PromiseExtensions.CancellationPoint to add a cancellation point to the chain of promises added IPromise<T> PromiseExtensions.Then<T>(this IPromise<T> that, Action<T> success) overloads added PromiseExtensions.Error() overloads to handle a error or(and) a cancellation

File last commit:

r205:8200ab154c8a v2
r207:558f34b2fb50 v2
Show More
MockRunnableComponent.cs
52 lines | 1.3 KiB | text/x-csharp | CSharpLexer
/ Implab.Test / Mock / MockRunnableComponent.cs
using System;
using Implab.Components;
namespace Implab.Test.Mock {
class MockRunnableComponent : RunnableComponent {
public MockRunnableComponent(bool initialized) : base(initialized) {
}
public MockRunnableComponent(bool initialized, bool reusable) : base(initialized, reusable) {
}
public Action MockInit {
get;
set;
}
public Func<IPromise> MockStart {
get;
set;
}
public Func<IPromise> MockStop {
get;
set;
}
public Action<bool, Exception> MockDispose {
get;
set;
}
protected override IPromise OnStart() {
return MockStart != null ? Safe.Run(MockStart).Chain(base.OnStart) : Safe.Run(base.OnStart);
}
protected override IPromise OnStop() {
return MockStop != null ? Safe.Run(MockStop).Chain(base.OnStop) : Safe.Run(base.OnStop);
}
protected override void OnInitialize() {
if (MockInit != null)
MockInit();
}
protected override void Dispose(bool disposing, Exception lastError) {
if (MockDispose != null)
MockDispose(disposing, lastError);
base.Dispose(disposing, lastError);
}
}
}