public void setting_empty_metadata_works()
        {
            _connection.SetStreamMetadataAsync(_stream, ExpectedVersion.EmptyStream, (byte[])null).Wait();

            var meta = _connection.GetStreamMetadataAsRawBytesAsync(_stream).Result;

            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 async Task setting_empty_metadata_works()
        {
            const string stream = "setting_empty_metadata_works";

            await _connection.SetStreamMetadataAsync(stream, ExpectedVersion.NoStream, (byte[])null);

            var meta = await _connection.GetStreamMetadataAsRawBytesAsync(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(0, meta.MetastreamVersion);
            Assert.AreEqual(new byte[0], meta.StreamMetadata);
        }
Exemple #3
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.DeleteStreamAsync(stream, ExpectedVersion.NoStream, hardDelete: false).Wait();

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

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

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

            var meta = _conn.GetStreamMetadataAsRawBytesAsync(stream).Result;

            Assert.AreEqual(1, meta.MetastreamVersion);
            Assert.AreEqual(new byte[256], meta.StreamMetadata);
        }
Exemple #4
0
        public void setting_empty_metadata_works()
        {
            _connection.SetStreamMetadataAsync(_stream, ExpectedVersion.Any, StreamMetadata.Create()).Wait();

            var meta = _connection.GetStreamMetadataAsRawBytesAsync(_stream).Result;

            Assert.AreEqual(_stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(0, meta.MetastreamVersion);
            Assert.AreEqual(Helper.UTF8NoBom.GetBytes("{}"), meta.StreamMetadata);
        }
        public async Task setting_empty_metadata_works()
        {
            const string stream = "setting_empty_metadata_works";

            await _connection.SetStreamMetadataAsync(stream, ExpectedVersion.NoStream, StreamMetadata.Create());

            var meta = await _connection.GetStreamMetadataAsRawBytesAsync(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(0, meta.MetastreamVersion);
            Assert.AreEqual(Helper.UTF8NoBom.GetBytes("{}"), meta.StreamMetadata);
        }
        public async Task when_getting_metadata_for_an_existing_stream_and_no_metadata_exists()
        {
            const string stream = "when_getting_metadata_for_an_existing_stream_and_no_metadata_exists";

            await _connection.AppendToStreamAsync(stream, ExpectedVersion.NoStream, TestEvent.NewTestEvent());

            var meta = await _connection.GetStreamMetadataAsRawBytesAsync(stream);

            Assert.AreEqual(stream, meta.Stream);
            Assert.AreEqual(false, meta.IsStreamDeleted);
            Assert.AreEqual(-1, meta.MetastreamVersion);
            Assert.AreEqual(Helper.UTF8NoBom.GetBytes(""), meta.StreamMetadata);
        }
Exemple #7
0
        setting_nonjson_metadata_on_empty_soft_deleted_stream_recreates_stream_keeping_original_metadataAsync()
        {
            const string stream =
                "setting_nonjson_metadata_on_empty_soft_deleted_stream_recreates_stream_overriding_metadata";

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

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

            await Task.Delay(50);             //TODO: This is a workaround until github issue #1744 is fixed

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

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

            var meta = await _conn.GetStreamMetadataAsRawBytesAsync(stream);

            Assert.AreEqual(1, meta.MetastreamVersion);
            Assert.AreEqual(new byte[256], meta.StreamMetadata);
        }
 protected void ReadMeta(string streamId, string login, string password)
 {
     Connection.GetStreamMetadataAsRawBytesAsync(streamId,
                                                 login == null && password == null ? null : new UserCredentials(login, password)).Wait();
 }
Exemple #9
0
 protected Task ReadMeta(string streamId, string login, string password)
 {
     return(Connection.GetStreamMetadataAsRawBytesAsync(streamId,
                                                        login == null && password == null ? null : new UserCredentials(login, password)));
 }