Ejemplo n.º 1
0
        public void setting_metadata_for_deleted_stream_throws_stream_deleted_exception()
        {
            const string stream = "setting_metadata_for_deleted_stream_throws_stream_deleted_exception";

            _connection.DeleteStream(stream, ExpectedVersion.NoStream, hardDelete: true);

            var metadataBytes = Guid.NewGuid().ToByteArray();

            Assert.That(() => _connection.SetStreamMetadata(stream, ExpectedVersion.EmptyStream, metadataBytes),
                        Throws.Exception.InstanceOf <AggregateException>()
                        .With.InnerException.InstanceOf <StreamDeletedException>());
        }
        public void ThrowsOnGetDeletedAggregate()
        {
            var aggregateId = SaveTestAggregateWithoutCustomHeaders(_repo, 10);

            var streamName = string.Format("testAggregate-{0}", aggregateId.ToString("N"));
            _connection.DeleteStream(streamName, 11);

            Assert.Throws<AggregateDeletedException>(() => _repo.GetById<TestAggregate>(aggregateId));
        }
Ejemplo n.º 3
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            _node = new MiniNode(PathName);
            _node.Start();

            _conn = TestConnection.Create(_node.TcpEndPoint);
            _conn.Connect();

            _eventId0 = Guid.NewGuid();
            _eventId1 = Guid.NewGuid();

            _conn.AppendToStream("test-stream",
                                 -1,
                                 new EventData(_eventId0, "event0", false, new byte[3], new byte[2]),
                                 new EventData(_eventId1, "event1", false, new byte[7], new byte[10]));
            _conn.DeleteStream("deleted-stream", -1);
        }
Ejemplo n.º 4
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            _node = new MiniNode(PathName);
            _node.Start();

            _conn = TestConnection.Create(_node.TcpEndPoint);
            _conn.Connect();

            _eventId0 = Guid.NewGuid();
            _eventId1 = Guid.NewGuid();

            _conn.AppendToStream("test-stream",
                                 -1, 
                                 new EventData(_eventId0, "event0", false, new byte[3], new byte[2]),
                                 new EventData(_eventId1, "event1", false, new byte[7], new byte[10]));
            _conn.DeleteStream("deleted-stream", -1, hardDelete: true);
        }
        public static void DeleteAllStreams(this IEventStoreConnection connection)
        {
            var slice = connection.ReadAllEventsForward(Position.Start, Int32.MaxValue, false,
                                                        EmbeddedEventStore.Instance.DefaultCredentials);
            var streams = slice.
                          Events.
                          Select(_ => _.OriginalStreamId).
                          Where(StreamNameIsNotReserved).
                          Distinct();

            foreach (var stream in
                     from _ in streams
                     let streamStatusSlice = connection.ReadStreamEventsForward(_, 0, 1, false)
                                             where streamStatusSlice.Status != SliceReadStatus.StreamDeleted &&
                                             streamStatusSlice.Status != SliceReadStatus.StreamNotFound
                                             select _)
            {
                connection.DeleteStream(stream, ExpectedVersion.Any, EmbeddedEventStore.Instance.DefaultCredentials);
            }
        }
        public void getting_metadata_for_deleted_stream_returns_empty_stream_metadata_and_signals_stream_deletion()
        {
            const string stream = "getting_metadata_for_deleted_stream_returns_empty_stream_metadata_and_signals_stream_deletion";

            var metadata = StreamMetadata.Create(17, TimeSpan.FromSeconds(0xDEADBEEF), TimeSpan.FromSeconds(0xABACABA));

            _connection.SetStreamMetadata(stream, ExpectedVersion.EmptyStream, metadata);

            _connection.DeleteStream(stream, ExpectedVersion.EmptyStream);

            var meta = _connection.GetStreamMetadata(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(true, meta.IsStreamDeleted);
            Assert.AreEqual(EventNumber.DeletedStream, meta.MetastreamVersion);
            Assert.AreEqual(null, meta.StreamMetadata.MaxCount);
            Assert.AreEqual(null, meta.StreamMetadata.MaxAge);
            Assert.AreEqual(null, meta.StreamMetadata.CacheControl);
            Assert.AreEqual(null, meta.StreamMetadata.Acl);
        }
Ejemplo n.º 7
0
 protected void DeleteStream(string streamId, string login, string password)
 {
     Connection.DeleteStream(streamId, ExpectedVersion.Any,
                             login == null && password == null ? null : new UserCredentials(login, password));
 }
 protected void HardDeleteStream(string stream)
 {
     _conn.DeleteStream(stream, ExpectedVersion.Any, true, _admin);
 }
Ejemplo n.º 9
0
        public void soft_deleted_stream_returns_no_stream_and_no_events_on_read()
        {
            const string stream = "soft_deleted_stream_returns_no_stream_and_no_events_on_read";

            Assert.AreEqual(1, _conn.AppendToStream(stream, ExpectedVersion.NoStream, TestEvent.NewTestEvent(), TestEvent.NewTestEvent()).NextExpectedVersion);
            _conn.DeleteStream(stream, 1);

            var res = _conn.ReadStreamEventsForward(stream, 0, 100, false);

            Assert.AreEqual(SliceReadStatus.StreamNotFound, res.Status);
            Assert.AreEqual(0, res.Events.Length);
            Assert.AreEqual(1, res.LastEventNumber);
        }