Hi,
Ok, hereis the code of the test concerned:
///
/// Test that multiple is readable after it has been written.
///
[Test]
public void WhenMultipleEventsAreWrittenToTheSinkTheyAreRetrievableFromTheEventStore()
{
var earlierTimestamp = new DateTimeOffset(2013, 05, 28, 22, 10, 20, 400, TimeSpan.FromHours(10));
var exception = new ArgumentException(“Mládek”);
const LogEventLevel level = LogEventLevel.Information;
const string messageTemplate = “{Song}++”;
var properties = new List
{
new LogEventProperty(“Song”, new ScalarValue(“New Macabre”))
};
var template = new MessageTemplateParser().Parse(messageTemplate);
var earlierLogEvent = new Events.LogEvent(earlierTimestamp, level, exception, template, properties);
//second event.
var laterTimestamp = new DateTimeOffset(2013, 05, 28, 22, 10, 20, 600, TimeSpan.FromHours(10));
var laterLogEvent = new Events.LogEvent(laterTimestamp, level, exception, template, properties);
var readEvents =new List(2);
var actualLogEvents = new List()
{
new LogEntryEmittedEvent(earlierLogEvent, earlierLogEvent.RenderMessage(null)),
new LogEntryEmittedEvent(laterLogEvent, laterLogEvent.RenderMessage(null))
};
IEventStoreConnection connection = null;
using (EventStoreRunner runner = new EventStoreRunner())
{
using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))
using (EventStoreSink sink = new EventStoreSink(connection, “Logs”, EventStoreSink.DefaultBatchPostingLimit, EventStoreSink.DefaultPeriod))
{
sink.Emit(earlierLogEvent);
}
//write a second event, in a different connection. This tests whether the reading/writing of the last event number
in the stream metadata works.
using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))
using (EventStoreSink sink = new EventStoreSink(connection, “Logs”, EventStoreSink.DefaultBatchPostingLimit, EventStoreSink.DefaultPeriod))
{
sink.Emit(laterLogEvent);
}
}
//Now, try and read both events using a catchup subscription.
using (EventStoreRunner runner = new EventStoreRunner())
using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))
{
connection.ConnectAsync();
EventStoreCatchUpSubscription sub =connection.SubscribeToStreamFrom(“Logs”, StreamCheckpoint.StreamStart, true,
EventArrived, GoingLive, ConnectionDropped);
}
Assert.That(readEvents, Is.EqualTo(actualLogEvents));
}
private void ConnectionDropped(EventStoreCatchUpSubscription arg1, SubscriptionDropReason arg2, Exception arg3)
{
throw new NotImplementedException();
}
private void GoingLive(EventStoreCatchUpSubscription obj)
{
throw new NotImplementedException();
}
private void EventArrived(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2)
{
throw new NotImplementedException();
}
All the sink is doing is writing essentially doing an append to stream, after accessing some stream metadata.
The EventStoreRunner is just a class to start/stop the eventstore process.
If you need these let me know.
Cheers
Sean.