public static void Wait(this ControlledTaskScheduler scheduler, IDataflowBlock block) { scheduler.Wait(); if (block.Completion.IsFaulted && block.Completion.Exception != null) { throw block.Completion.Exception; } }
public Delay50MsNoFiltering() { _fileSystem = Substitute.For<IFileSystem>(); var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem); _fileSystemFilter = Substitute.For<IMsBuildFileSystemFilter>(); _fileSystemFilter.IsFileAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); _fileSystemFilter.IsDirectoryAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current); _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 50, 50, _fileSystem, _fileSystemFilter, Substitute.For<IActionLog>(), _taskScheduler); _taskScheduler.Link(_fileSystemWatcher.SourceBlock, c => { _changeset = c; }); _fileSystemWatcher.Start(); _fileWatcher = watchers.FileWatcher; _directoryWatcher = watchers.DirectoryWatcher; _attributesWatcher = watchers.AttributesWatcher; }
public NoDelayNoFiltering() { _fileSystem = Substitute.For<IFileSystem>(); _fileSystem.GetFileAttributes(Arg.Any<string>()).Throws<FileNotFoundException>(); var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem); var fileSystemFilter = Substitute.For<IMsBuildFileSystemFilter>(); fileSystemFilter.IsFileAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); fileSystemFilter.IsDirectoryAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current); _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 0, _fileSystem, fileSystemFilter, _taskScheduler, NullLog.Instance); _fileSystemWatcher.Start(); _fileWatcher = watchers.FileWatcher; _directoryWatcher = watchers.DirectoryWatcher; _attributesWatcher = watchers.AttributesWatcher; }
public NoDelayNoFiltering() { _fileSystem = Substitute.For<IFileSystem>(); _fileSystem.GetFileAttributes(Arg.Any<string>()).Throws<FileNotFoundException>(); _fileSystem.ToLongPath(Arg.Any<string>()).Returns(ci => ci[0]); _fileSystem.ToShortPath(Arg.Any<string>()).Returns(ci => ci[0]); var watchers = GetWatchersFromMsBuildFileSystemWatcher(_fileSystem); var fileSystemFilter = Substitute.For<IMsBuildFileSystemFilter>(); fileSystemFilter.IsFileAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); fileSystemFilter.IsDirectoryAllowed(Arg.Any<string>(), Arg.Any<FileAttributes>()).ReturnsForAnyArgs(true); _taskScheduler = new ControlledTaskScheduler(SynchronizationContext.Current); DirectoryInfoStubFactory.Create(_fileSystem, ProjectDirectory); _fileSystemWatcher = new MsBuildFileSystemWatcher(ProjectDirectory, "*", 0, 0, _fileSystem, fileSystemFilter, Substitute.For<IActionLog>(), _taskScheduler); _fileSystemWatcher.Start(); _fileWatcher = watchers.FileWatcher; _directoryWatcher = watchers.DirectoryWatcher; _attributesWatcher = watchers.AttributesWatcher; }
public ControlledTaskSchedulerTest() { _scheduler = new ControlledTaskScheduler(SynchronizationContext.Current); }
public static void Link <T>(this ControlledTaskScheduler scheduler, IReceivableSourceBlock <T> sourceBlock, Action <T> action) { sourceBlock.LinkTo(new ActionBlock <T>(action, new ExecutionDataflowBlockOptions { TaskScheduler = scheduler })); }