LoadEvents() public method

public LoadEvents ( string context, string streamId, long fromVersion, long maxVersion = null ) : Res.Core.Storage.EventInStorage[]
context string
streamId string
fromVersion long
maxVersion long
return Res.Core.Storage.EventInStorage[]
Example #1
0
        public void should_store_messages()
        {
            var storage = new InMemoryEventStorage();
            var writer = new EventStorageWriter(10, TimeSpan.FromMinutes(1), storage);

            writer.Start(_token.Token);

            var task1 = writer.Store(new CommitForStorage("foo", "stream1",
                                              new EventForStorage(Guid.NewGuid(), 1, DateTime.Now, "type", null, "body")));
            var task2 = writer.Store(new CommitForStorage("foo", "stream2",
                                              new EventForStorage(Guid.NewGuid(), 1, DateTime.Now, "type", null, "body")));

            Task.WhenAll(task1, task2).Wait(1000);

            var stream1Events = storage.LoadEvents("foo", "stream1");
            var stream2Events = storage.LoadEvents("foo", "stream2");

            Assert.AreEqual(1, stream1Events.Length, "stream1 should have one event.");
            Assert.AreEqual(1, stream2Events.Length, "stream2 should have one event.");
        }