Esempio n. 1
0
        public void returns_all_events_including_tombstone()
        {
            var metadataEvents = _conn.ReadStreamEventsBackwardAsync("$$" + _stream, -1, 1, true, new UserCredentials("admin", "changeit")).Result;
            var lastEvent      = metadataEvents.Events[0].Event;

            Assert.AreEqual("$$" + _stream, lastEvent.EventStreamId);
            Assert.AreEqual(SystemEventTypes.StreamMetadata, lastEvent.EventType);
            var metadata = StreamMetadata.FromJsonBytes(lastEvent.Data);

            Assert.AreEqual(EventNumber.DeletedStream, metadata.TruncateBefore);
        }
 public Task <StreamMetadataResult> GetStreamMetadataAsync(string stream, UserCredentials userCredentials = null)
 {
     return(GetStreamMetadataAsRawBytesAsync(stream, userCredentials).ContinueWith(t =>
     {
         if (t.Exception != null)
         {
             throw t.Exception.InnerException;
         }
         var res = t.Result;
         if (res.StreamMetadata == null || res.StreamMetadata.Length == 0)
         {
             return new StreamMetadataResult(res.Stream, res.IsStreamDeleted, res.MetastreamVersion, StreamMetadata.Create());
         }
         var metadata = StreamMetadata.FromJsonBytes(res.StreamMetadata);
         return new StreamMetadataResult(res.Stream, res.IsStreamDeleted, res.MetastreamVersion, metadata);
     }));
 }
        public void returns_all_events_including_tombstone()
        {
            AllEventsSlice read = _conn.ReadAllEventsForwardAsync(Position.Start, _testEvents.Length + 10, false).Result;

            Assert.That(
                EventDataComparer.Equal(
                    _testEvents.ToArray(),
                    read.Events.Skip(read.Events.Length - _testEvents.Length - 1)
                    .Take(_testEvents.Length)
                    .Select(x => x.Event)
                    .ToArray()));
            var lastEvent = read.Events.Last().Event;

            Assert.AreEqual("$$stream", lastEvent.EventStreamId);
            Assert.AreEqual(SystemEventTypes.StreamMetadata, lastEvent.EventType);
            var metadata = StreamMetadata.FromJsonBytes(lastEvent.Data);

            Assert.AreEqual(EventNumber.DeletedStream, metadata.TruncateBefore);
        }