static async Task SetupAndRunTests(this IStorageFactory storageFactory, TimeSpan?withDelay = null) { using var folderChangeWatcher = storageFactory.CreateChangeWatcher(); using var subscription = folderChangeWatcher.FolderChanged.Subscribe(path => { Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.WriteLine($"File in folder '{path}' was changed"); Console.ForegroundColor = ConsoleColor.Black; }); //Task.Run(() => { Thread.Sleep(4000); subscription.Dispose(); Console.WriteLine("subscription cancelled"); }); await storageFactory.CreateStorageService().RunTestActions(withDelay); await Task.Delay(1000); }