public void When_including_unconditional_delete_for_transient_entity()
        {
            var entity = new TestEntity(EntityRowKey)
            {
                ETag = "*"
            };

            Assert.Throws <StorageException>(() =>
                                             Stream.Write(stream, CreateEvent(Include.Delete(entity))),
                                             "Will be always executed and exception will be thrown by the storage");
        }
예제 #2
0
        public void When_Delete_followed_by_Delete()
        {
            var entity = new TestEntity(EntityRowKey);

            var events = new[]
            {
                CreateEvent(Include.Delete(entity)),
                CreateEvent(Include.Delete(entity))
            };

            var exception = Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                                           Stream.WriteAsync(stream, events));

            Assert.That(exception,
                        Has.Message.Contains("cannot be followed by"));
        }
예제 #3
0
        public async Task When_Insert_followed_by_Delete()
        {
            var entity = new TestEntity(EntityRowKey);

            var events = new[]
            {
                CreateEvent(Include.Insert(entity)),
                CreateEvent(Include.Delete(entity))
            };

            await Stream.WriteAsync(stream, events);

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored, Is.Null,
                        "NULL since Insert interdifused with Delete");
        }
예제 #4
0
        public async Task When_Null_followed_by_Insert_Or_Replace()
        {
            var entity = new TestEntity(EntityRowKey);

            var events = new[]
            {
                CreateEvent(Include.Insert(entity)), // that combination
                CreateEvent(Include.Delete(entity)), //  produces NULL

                CreateEvent(Include.InsertOrReplace(entity))
            };

            await Stream.WriteAsync(stream, events);

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored, Is.Not.Null);
        }
예제 #5
0
        public void When_Null_followed_by_Delete()
        {
            var entity = new TestEntity(EntityRowKey);

            var events = new[]
            {
                CreateEvent(Include.Insert(entity)), // that combination
                CreateEvent(Include.Delete(entity)), //  produces NULL

                CreateEvent(Include.Delete(entity))
            };

            var exception = Assert.ThrowsAsync <InvalidOperationException>(() =>
                                                                           Stream.WriteAsync(stream, events));

            Assert.That(exception,
                        Has.Message.Contains("cannot be applied to NULL"));
        }
예제 #6
0
        public async Task When_Replace_followed_by_Delete()
        {
            var entity = new TestEntity(EntityRowKey);

            InsertTestEntity(entity);

            var events = new[]
            {
                CreateEvent(Include.Replace(entity)),
                CreateEvent(Include.Delete(entity))
            };

            await Stream.WriteAsync(stream, events);

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored, Is.Null, "Delete should win");
        }
        public void When_Null_followed_by_Insert()
        {
            var entity = new TestEntity(EntityRowKey);

            var events = new[]
            {
                CreateEvent(Include.Insert(entity)), // that combination
                CreateEvent(Include.Delete(entity)), //  produces NULL

                CreateEvent(Include.Insert(entity))
            };

            Stream.Write(stream, events);

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored, Is.Not.Null);
        }
예제 #8
0
        public async Task When_including_mutually_soluble_operations()
        {
            var entity = new TestEntity(EntityRowKey)
            {
                Data = "12"
            };

            EventData[] events =
            {
                CreateEvent(Include.Insert(entity)),
                CreateEvent(Include.Delete(entity))
            };

            await Stream.WriteAsync(stream, events);

            var stored = RetrieveTestEntity(entity.RowKey);

            Assert.That(stored, Is.Null);
        }
        public void When_including_mutually_soluble_operations_chained_indirectly()
        {
            var entity = new TestEntity(EntityRowKey)
            {
                Data = "12"
            };

            EventData[] events =
            {
                CreateEvent(Include.Insert(entity)),
                CreateEvent(Include.Replace(entity)),
                CreateEvent(Include.Delete(entity))
            };

            Stream.Write(stream, events);

            var stored = RetrieveTestEntity(entity.RowKey);

            Assert.That(stored, Is.Null);
        }
예제 #10
0
        public void When_including_unconditional_delete()
        {
            var entity = new TestEntity(EntityRowKey)
            {
                Data = "123"
            };

            InsertTestEntity(entity);

            entity = new TestEntity(EntityRowKey)
            {
                ETag = "*"
            };
            Assert.DoesNotThrowAsync(() =>
                                     Stream.WriteAsync(stream, CreateEvent(Include.Delete(entity))),
                                     "Will be always executed and will delete row");

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored, Is.Null);
        }
예제 #11
0
        public async Task When_Delete_followed_by_Insert()
        {
            //  transition of Delete -> Insert = Replace is safe,
            //  since you can only get here by either starting from Replace or Delete
            //  which means you either have Etag or *
            //  that's why there is an asumption that entity exists

            var entity = new TestEntity(EntityRowKey);

            InsertTestEntity(entity);

            entity.Data = "zzz";
            var events = new[]
            {
                CreateEvent(Include.Delete(entity)),
                CreateEvent(Include.Insert(entity))
            };

            await Stream.WriteAsync(stream, events);

            var stored = RetrieveTestEntity(EntityRowKey);

            Assert.That(stored.Data, Is.EqualTo("zzz"));
        }