Exemple #1
0
        public void setting_empty_metadata_works()
        {
            const string stream = "setting_empty_metadata_works";

            _connection.SetStreamMetadata(stream, ExpectedVersion.EmptyStream, (byte[])null);

            var meta = _connection.GetStreamMetadataAsRawBytes(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(0, meta.MetastreamVersion);
            Assert.AreEqual(new byte[0], meta.StreamMetadata);
        }
Exemple #2
0
        public void setting_nonjson_metadata_on_empty_soft_deleted_stream_recreates_stream_keeping_original_metadata()
        {
            const string stream = "setting_nonjson_metadata_on_empty_soft_deleted_stream_recreates_stream_overriding_metadata";

            _conn.DeleteStream(stream, ExpectedVersion.NoStream, hardDelete: false);

            Assert.AreEqual(1, _conn.SetStreamMetadata(stream, 0, new byte[256]).NextExpectedVersion);

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

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

            var meta = _conn.GetStreamMetadataAsRawBytes(stream);

            Assert.AreEqual(1, meta.MetastreamVersion);
            Assert.AreEqual(new byte[256], meta.StreamMetadata);
        }
        public void setting_empty_metadata_works()
        {
            const string stream = "setting_empty_metadata_works";

            _connection.SetStreamMetadata(stream, ExpectedVersion.EmptyStream, StreamMetadata.Create());

            var meta = _connection.GetStreamMetadataAsRawBytes(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(0, meta.MetastreamVersion);
            Assert.AreEqual(Helper.UTF8NoBom.GetBytes("{}"), meta.StreamMetadata);
        }
 protected void ReadMeta(string streamId, string login, string password)
 {
     Connection.GetStreamMetadataAsRawBytes(streamId, login == null && password == null ? null : new UserCredentials(login, password));
 }