AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
net5.0-windows net5.0-windows was computed. Versions Compatible and additional computed target framework versions. Var text = _file.ReadAllText(e.FullPath) Private void Watcher_Created(object sender, System.IO.FileSystemEventArgs e) This._watcher.Created += Watcher_Created Public SomeClassUsingFileSystemWatcher(IFileSystemWatcher watcher, IFile file) Var fileSystem = new MockFileSystem(new Dictionary Public void M圜omponent_Validate_ShouldThrowNotSupportedExceptionIfTestingIsNotAwesome() dotnet add package System.IO.Abstractions.TestingHelpers They are not a complete copy of a real-life file system, but they'll get you most of the way there. The library also ships with a series of test helpers to save you from having to mock out every call, for basic scenarios. Throw new NotSupportedException("We can't go on together. Public M圜omponent(IFileSystem fileSystem)įileSystem: new FileSystem() //use default implementation which calls System.IOįoreach (var textFile in "*.txt", SearchOption.TopDirectoryOnly)) Create M圜omponent with the given fileSystem implementation dotnet add package System.IO.Abstractions We have exactly the same API, except that ours is injectable and testable. Instead of calling methods like File.ReadAllText directly, use. At the core of the library is IFileSystem and FileSystem.
0 Comments
Read More
Leave a Reply. |