Exemple #1
0
 protected Task TestStore(
     Context context,
     ITestClock clock,
     IContentChangeAnnouncer announcer,
     Func <TestFileSystemContentStoreInternal, Task> func)
 {
     return(TestStoreImpl(context, clock, func, announcer: announcer));
 }
        private async Task TestStoreImpl
        (
            Context context,
            ITestClock clock,
            Func <TestFileSystemContentStoreInternal, Task> func,
            DisposableDirectory testDirectory   = null,
            IContentChangeAnnouncer announcer   = null,
            NagleQueue <ContentHash> nagleBlock = null,
            Action <TestFileSystemContentStoreInternal> preStartupAction = null
        )
        {
            using (var tempTestDirectory = new DisposableDirectory(FileSystem))
            {
                DisposableDirectory disposableDirectory = testDirectory ?? tempTestDirectory;
                using (var store = Create(disposableDirectory.Path, clock, nagleBlock))
                {
                    if (announcer != null)
                    {
                        store.Announcer = announcer;
                    }

                    store.Should().NotBeNull();
                    try
                    {
                        preStartupAction?.Invoke(store);
                        var r = await store.StartupAsync(context);

                        r.ShouldBeSuccess();
                        await func(store);
                    }
                    finally
                    {
                        if (!store.ShutdownStarted)
                        {
                            await store.ShutdownAsync(context).ShouldBeSuccess();
                        }
                    }
                }
            }
        }
Exemple #3
0
        private async Task TestStore(Context context, Func <TStore, Task> func, IContentChangeAnnouncer announcer = null)
        {
            using (var testDirectory = new DisposableDirectory(FileSystem))
            {
                using (var store = CreateStore(testDirectory))
                {
                    if (announcer != null)
                    {
                        store.Announcer = announcer;
                    }

                    store.Should().NotBeNull();
                    try
                    {
                        await store.StartupAsync(context).ShouldBeSuccess();
                        await func(store);
                    }
                    finally
                    {
                        await store.ShutdownAsync(context).ShouldBeSuccess();
                    }
                }
            }
        }