public async Task MultipleDeleteListeners()
        {
            var store        = this.NewStore(1);
            var anotherStore = this.NewStore(2);

            var deleteListener = new DeleteNotReadOnlyFilesListener();
            var noOpListener   = new NoOpDeleteFilesListener();

            store.Listeners.RegisterListener(deleteListener);
            store.Listeners.RegisterListener(noOpListener);

            using (var session = store.OpenAsyncSession())
            {
                session.RegisterUpload("/b/test1.file", CreateUniformFileStream(128));
                session.RegisterUpload("/b/test2.file", CreateUniformFileStream(128));
                await session.SaveChangesAsync();

                var file = await session.LoadFileAsync("/b/test1.file");

                file.Metadata.Add("Read-Only", true);
                await session.SaveChangesAsync();

                session.RegisterFileDeletion("/b/test1.file");
                session.RegisterFileDeletion("/b/test2.file");
                await session.SaveChangesAsync();

                Assert.Equal(2, deleteListener.AfterCount + noOpListener.AfterCount);
                Assert.Equal(4, deleteListener.BeforeCount + noOpListener.BeforeCount);
            }
        }
Exemplo n.º 2
0
        public async Task NoOpDeleteListener()
        {
            var store = this.NewStore(1);
            var anotherStore = this.NewStore(2);

            var noOpListener = new NoOpDeleteFilesListener();
            store.Listeners.RegisterListener(noOpListener);

            using (var session = store.OpenAsyncSession())
            {
                session.RegisterUpload("/b/test1.file", CreateUniformFileStream(128));
                session.RegisterUpload("/b/test2.file", CreateUniformFileStream(128));
                await session.SaveChangesAsync();

                session.RegisterFileDeletion("/b/test1.file");
                session.RegisterFileDeletion("/b/test2.file");
                await session.SaveChangesAsync();

                Assert.Equal(2, noOpListener.AfterCount);

                var file = await session.LoadFileAsync("/b/test1.file");
                var file2 = await session.LoadFileAsync("/b/test2.file");

                Assert.Null(file);
                Assert.Null(file2);
            }
        }
        public async Task NoOpDeleteListener()
        {
            var store        = this.NewStore(1);
            var anotherStore = this.NewStore(2);

            var noOpListener = new NoOpDeleteFilesListener();

            store.Listeners.RegisterListener(noOpListener);

            using (var session = store.OpenAsyncSession())
            {
                session.RegisterUpload("/b/test1.file", CreateUniformFileStream(128));
                session.RegisterUpload("/b/test2.file", CreateUniformFileStream(128));
                await session.SaveChangesAsync();

                session.RegisterFileDeletion("/b/test1.file");
                session.RegisterFileDeletion("/b/test2.file");
                await session.SaveChangesAsync();

                Assert.Equal(2, noOpListener.AfterCount);

                var file = await session.LoadFileAsync("/b/test1.file");

                var file2 = await session.LoadFileAsync("/b/test2.file");

                Assert.Null(file);
                Assert.Null(file2);
            }
        }
Exemplo n.º 4
0
        public async void MultipleDeleteListeners()
        {
            var store = this.NewStore(1);
            var anotherStore = this.NewStore(2);

            var deleteListener = new DeleteNotReadOnlyFilesListener();
            var noOpListener = new NoOpDeleteFilesListener();
            store.Listeners.RegisterListener(deleteListener);
            store.Listeners.RegisterListener(noOpListener);

            using (var session = store.OpenAsyncSession())
            {
                session.RegisterUpload("/b/test1.file", CreateUniformFileStream(128));
                session.RegisterUpload("/b/test2.file", CreateUniformFileStream(128));
                await session.SaveChangesAsync();

                var file = await session.LoadFileAsync("/b/test1.file");
                file.Metadata.Add("Read-Only", true);
                await session.SaveChangesAsync();

                session.RegisterFileDeletion("/b/test1.file");
                session.RegisterFileDeletion("/b/test2.file");
                await session.SaveChangesAsync();

                Assert.Equal(2, deleteListener.AfterCount + noOpListener.AfterCount);
                Assert.Equal(4, deleteListener.BeforeCount + noOpListener.BeforeCount);
            }
        }