Beispiel #1
0
        public void notify_using_status_code_if_stream_not_found()
        {
            var res = _conn.ReadEvent("unexisting-stream", 5, false);

            Assert.AreEqual(EventReadStatus.NoStream, res.Status);
            Assert.IsNull(res.Event);
            Assert.AreEqual("unexisting-stream", res.Stream);
            Assert.AreEqual(5, res.EventNumber);
        }
        private static int?GetLastEventNumber(this IEventStoreConnection connection, string streamName)
        {
            var lastEvent = connection.ReadEvent(streamName, -1, false, EventStoreCredentials.Default);

            if (lastEvent == null || lastEvent.Event == null)
            {
                return(null);
            }

            return(lastEvent.Event.Value.OriginalEventNumber);
        }
        public static T GetLastEvent <T>(this IEventStoreConnection connection, string streamName)
            where T : class
        {
            var lastEvent = connection.ReadEvent(streamName, -1, false, EventStoreCredentials.Default);

            if (lastEvent == null || lastEvent.Event == null)
            {
                return(null);
            }

            return(lastEvent.Event.Value.ParseJson <T>());
        }
 protected void ReadEvent(string streamId, string login, string password)
 {
     Connection.ReadEvent(streamId, -1, false,
                          login == null && password == null ? null : new UserCredentials(login, password));
 }
        public void read_event_respects_truncatebefore()
        {
            const string stream = "read_event_respects_truncatebefore";

            _connection.AppendToStream(stream, ExpectedVersion.EmptyStream, _testEvents);

            _connection.SetStreamMetadata(stream, ExpectedVersion.EmptyStream, StreamMetadata.Build().SetTruncateBefore(2));

            var res = _connection.ReadEvent(stream, 1, false);

            Assert.AreEqual(EventReadStatus.NotFound, res.Status);

            res = _connection.ReadEvent(stream, 2, false);
            Assert.AreEqual(EventReadStatus.Success, res.Status);
            Assert.AreEqual(_testEvents[2].EventId, res.Event.Value.OriginalEvent.EventId);
        }