You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Just like `System.Web.Abstractions`, but for `System.IO`. Yay for testable IO access!
15
7
16
8
At the core of the library is `IFileSystem` and `FileSystem`. Instead of calling methods like `File.ReadAllText` directly, use `IFileSystem.File.ReadAllText`. We have exactly the same API, except that ours is injectable and testable.
17
9
10
+
dotnet add package System.IO.Abstractions
11
+
18
12
```csharp
19
13
publicclassMyComponent
20
14
{
@@ -26,7 +20,7 @@ public class MyComponent
26
20
this.fileSystem=fileSystem;
27
21
}
28
22
/// <summary>Create MyComponent</summary>
29
-
publicMyComponent() : this(
23
+
publicMyComponent() : this(
30
24
fileSystem: newFileSystem() //use default implementation which calls System.IO
31
25
)
32
26
{
@@ -46,6 +40,8 @@ public class MyComponent
46
40
47
41
The library also ships with a series of test helpers to save you from having to mock out every call, for basic scenarios. They are not a complete copy of a real-life file system, but they'll get you most of the way there.
0 commit comments