Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public interface IEventStoreTest
{
}
internal static class EventStoreTestMixins
{
...
public static EventStoreHelper StartInMemStore(this IEventStoreTest test)
{
KillExistingEventStore();
var process = new Process();
process.StartInfo = new ProcessStartInfo(EventStorePath, "--mem-db --run-projections=all")
{
RedirectStandardOutput = true,
CreateNoWindow = true,
UseShellExecute = false
};
var mre = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(state =>
{
process.Start();
while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
if (!string.IsNullOrEmpty(line) && line.Contains("SPARTA"))
{
mre.Set();
}
}
});
if (!mre.WaitOne(TimeSpan.FromSeconds(10)))
{
throw new InvalidOperationException("Event Store not started in 10 secs");
}
return new EventStoreHelper(BuildConnection(), new ActionDisposable(process.Kill));
}
}
public sealed class SomeEventStoreTest : IEventStoreTest
{
private readonly EventStoreHelper store;
public SomeEventStoreTest()
{
store = this.StartInMemStore();
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.