ToolBX.NetAbstractions
1.0.2
See the version list below for details.
dotnet add package ToolBX.NetAbstractions --version 1.0.2
NuGet\Install-Package ToolBX.NetAbstractions -Version 1.0.2
<PackageReference Include="ToolBX.NetAbstractions" Version="1.0.2" />
paket add ToolBX.NetAbstractions --version 1.0.2
#r "nuget: ToolBX.NetAbstractions, 1.0.2"
// Install ToolBX.NetAbstractions as a Cake Addin
#addin nuget:?package=ToolBX.NetAbstractions&version=1.0.2
// Install ToolBX.NetAbstractions as a Cake Tool
#tool nuget:?package=ToolBX.NetAbstractions&version=1.0.2
NetAbstractions
Abstractions for .NET base types such as File and Directory to provide easier means to mock low-level operations.
For some strange and obscure reason, Microsoft thought it was a good idea to have unmockable static classes for most low-level operations such as deleting files and folders. Suppose you want to test a method that checks whether a file exists and delete it if it does? You could create temporary files to be used with your tests. It could work but it would also needlessly complexify your tests’ logic. You might also be tempted to just not test that method. It’s fine if you don’t care about code quality. It’s okay, I’m not judging (I am.)
Using this library, you can do the following:
public class ShadyService : IShadyService
{
private readonly IFile _file;
public ShadyService(IFile file)
{
_file = file;
}
public void DoTheThing(string path)
{
if (_file.Exists(path))
_file.Delete(path);
}
}
Getting started
Thankfully, NetAbstractions uses AutoInject to inject all those wrappers for you. You do still need to call this one line :
public void ConfigureServices(IServiceCollection services)
{
services.AddAutoInjectServices();
}
See AutoInject's repo for more info
You can also add them one by one if that's what you want but that would be weird.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- ToolBX.AutoInject (>= 1.0.1)
- ToolBX.EasyTypeParsing (>= 1.0.0)
- ToolBX.Mathemancy (>= 1.0.3)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ToolBX.NetAbstractions:
Package | Downloads |
---|---|
ToolBX.FileGuy
High-level API for handling files. |
|
ToolBX.MisterTerminal
A high level library to easily and cleanly build smarter console applications. |
|
ToolBX.FileGuy.Json
Adds a FileSerializer service which takes advantage of FileGuy's features to serialize objects to file using Microsoft's System.Text json library. |
|
ToolBX.ProjectMaster
Provides a base class to format and access application data paths in an easy and straightforward way. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.0 | 594 | 1/13/2024 |
2.2.0-beta2 | 140 | 1/7/2024 |
2.2.0-beta1 | 82 | 12/21/2023 |
2.0.3 | 298 | 6/19/2023 |
2.0.2 | 149 | 6/11/2023 |
2.0.2-beta1 | 116 | 5/9/2023 |
2.0.1 | 409 | 4/26/2023 |
2.0.0 | 457 | 11/10/2022 |
2.0.0-beta1 | 191 | 9/27/2022 |
1.0.8 | 871 | 9/27/2022 |
1.0.7 | 410 | 7/31/2022 |
1.0.6 | 418 | 7/20/2022 |
1.0.5 | 416 | 7/6/2022 |
1.0.4 | 406 | 7/5/2022 |
1.0.3 | 432 | 6/23/2022 |
1.0.2.5-beta | 635 | 5/17/2022 |
1.0.2.4-beta | 460 | 5/15/2022 |
1.0.2.3-beta | 137 | 5/15/2022 |
1.0.2.2-beta | 140 | 5/15/2022 |
1.0.2.1-beta | 145 | 5/6/2022 |
1.0.2 | 439 | 5/2/2022 |
1.0.1 | 426 | 4/29/2022 |
1.0.0 | 285 | 1/10/2022 |