Beispiel #1
0
        public async Task PutAnnouncesAdd()
        {
            var context       = new Context(Logger);
            var mockAnnouncer = new TestContentChangeAnnouncer();

            await TestStore(
                context,
                async store =>
            {
                store.Announcer.Should().NotBeNull();
                using (var stream = new MemoryStream(ThreadSafeRandom.GetBytes(ValueSize)))
                {
                    await store.PutStreamAsync(context, stream, ContentHashType).ShouldBeSuccess();
                }
            },
                announcer : mockAnnouncer
                );

            mockAnnouncer.ContentAddedCalled.Should().BeTrue();
        }
        public async Task PutStreamPurgeAnnouncesRemove()
        {
            var mockAnnouncer = new TestContentChangeAnnouncer();

            await TestStore(Context, Clock, mockAnnouncer, async store =>
            {
                store.Announcer.Should().NotBeNull();

                var cas      = store as FileSystemContentStoreInternal;
                var blobSize = BlobSizeToStartSoftPurging(2);

                using (var stream1 = new MemoryStream(ThreadSafeRandom.GetBytes(blobSize)))
                    using (var stream2 = new MemoryStream(ThreadSafeRandom.GetBytes(blobSize)))
                    {
                        await cas.PutStreamAsync(Context, stream1, ContentHashType).ShouldBeSuccess();
                        Clock.Increment();
                        await cas.PutStreamAsync(Context, stream2, ContentHashType).ShouldBeSuccess();
                        Clock.Increment();
                        await store.SyncAsync(Context);
                    }
            });

            mockAnnouncer.ContentEvictedCalled.Should().BeTrue();
        }