All Projects → PawelGerr → Thinktecture.Abstractions

PawelGerr / Thinktecture.Abstractions

Licence: BSD-3-Clause License
Interfaces for commonly used .NET types like `File`, `Directory`, `Stream`, `Path`, `Math`, `Environment`, `Task`, etc. for better testability.

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to Thinktecture.Abstractions

DataAbstractions.Dapper
A light abstraction around Dapper and Dapper.Contrib that also maintains the behavior IDbConnection.
Stars: ✭ 37 (+48%)
Mutual labels:  abstractions, testability
TestableDesignExample
Sample App to learn a testable design (Smalltalk flavored MVC)
Stars: ✭ 80 (+220%)
Mutual labels:  testability
mole
A tool for managing design decision outputs for different platforms
Stars: ✭ 30 (+20%)
Mutual labels:  abstractions
pypely
Make your data processing easy
Stars: ✭ 17 (-32%)
Mutual labels:  testability
three-stdlib
📚 Stand-alone library of threejs examples designed to run without transpilation in node & browser
Stars: ✭ 380 (+1420%)
Mutual labels:  abstractions
refactoring-for-testability-cpp
Hard-to-test patterns in C++ and how to refactor them
Stars: ✭ 40 (+60%)
Mutual labels:  testability
robotframework-seleniumtestability
Extension for SeleniumLibrary that provides manual and automatic waiting for asyncronous events like fetch, xhr, etc.
Stars: ✭ 34 (+36%)
Mutual labels:  testability
Http4k
The Functional toolkit for Kotlin HTTP applications. http4k provides a simple and uniform way to serve, consume, and test HTTP services.
Stars: ✭ 1,883 (+7432%)
Mutual labels:  testability
Powermock
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.
Stars: ✭ 3,708 (+14732%)
Mutual labels:  testability
Swift Composable Architecture
A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
Stars: ✭ 5,199 (+20696%)
Mutual labels:  testability

Build Thinktecture.Abstractions

Interfaces for commonly used .NET types like File, Directory, Stream, Path, Math, Environment, etc. to be able to extend or to change the standard behavior and for better testability.

  • The interfaces have the same API like the .NET types
  • Support of .NET Standard 2.1, .NET Core 3.1 and .NET 5.0

Read my blog ".NET Abstractions - It's not just about testing!" for more info about the design decisions I made.

Usage

Just use the interface like IFile instead of File.

More examples:

public class MyClass
{
	private readonly IFile _file;
	
	public MyClass(IFile file)
	{
		_file = file;
	}

	public void MyMethod(string filePath)
	{
		...
		bool exists = _file.Exists(filePath);
		...
	}
}

Usage of static types

The projects containing the interfaces provide adapters (wrappers) that are using the static .NET classes internally.

IFile file = new FileAdapter();

Usage of non-static types

Either use the adapters like with static types or use the extension methods in namespace Thinktecture.

FileInfo fileInfo = ...;

IFileInfo fileInfoInterface = fileInfo.ToInterface();

If you need back the .NET type i.e. to call a method that does not support the abstrations just call ToImplementation()

IFileInfo fileInfoInterface = ...

FileInfo fileInfo = fileInfoInterface.ToImplementation();

Resharper: if you are using Resharper then you will see another member UnsafeConvert(). This member is for implementers of the interface only and it is not intended to be used directly.

Projects

The projects are mirroring the .NET assemblies, i.e. if the class Stream is in System.IO.dll then the interface IStream will be in Thinktecture.IO.Abstractions.dll.

Thinktecture.Net.Sockets.Abstractions

Provides interfaces for types in System.Net.Sockets: Socket, TcpClient, UdpClient, TcpListener, NetworkStream, ISocketAsyncEventArgs, LingerOption, SendPacketsElement.

Nuget: Install-Package Thinktecture.Net.Sockets.Abstractions

Thinktecture.Net.NetworkInformation.Abstractions

Provides interfaces for types in System.Net.NetworkInformation: NetworkInterface, PhysicalAddress, IPAddressInformation, IPAddressInformationCollection, IPInterfaceProperties, IPInterfaceStatistics, IPv4InterfaceProperties, IPv6InterfaceProperties, UnicastIPAddressInformation, UnicastIPAddressInformationCollection, MulticastIPAddressInformation, MulticastIPAddressInformationCollection, GatewayIPAddressInformation, GatewayIPAddressInformationCollection.

Nuget: Install-Package Thinktecture.Net.NetworkInformation.Abstractions

Thinktecture.Net.Http.Abstractions

Provides interfaces for types in System.Net.Http: HttpClient, HttpContent, HttpRequestMessage, HttpResponseMessage, HttpHeaders, HttpHeaderValueCollection, DelegatingHandler, HttpClientHandler, HttpMessageHandler, HttpMessageInvoker, MessageProcessingHandler, MultipartContent, MultipartFormDataContent, HttpContentHeaders, HttpRequestHeaders, HttpResponseHeaders.

Nuget: Install-Package Thinktecture.Net.Http.Abstractions

Thinktecture.Net.Primitives.Abstractions

Provides interfaces for types in System.Net.Primitives: IPAddress, IPEndPoint, NetworkCredential, EndPoint, Cookie, DnsEndPoint, SocketAddress, CookieCollection, CookieContainer, CredentialCache, TransportContext, ChannelBinding.

Nuget: Install-Package Thinktecture.Net.Primitives.Abstractions

Thinktecture.IO.FileSystem.Watcher.Abstractions

Provides interfaces for types in System.IO.FileSystem.Watcher: FileSystemWatcher.

Nuget: Install-Package Thinktecture.IO.FileSystem.Watcher.Abstractions

Thinktecture.IO.FileSystem.Abstractions

Provides interfaces for types in System.IO.FileSystem: Directory, File, FileSystemInfo, DirectoryInfo, FileInfo, FileStream, SafeFileHandle.

Nuget: Install-Package Thinktecture.IO.FileSystem.Abstractions

Thinktecture.IO.Abstractions

Provides interfaces for types in System.IO: Stream, MemoryStream, BinaryReader, BinaryWriter, StreamReader, StreamWriter, StringReader, StringWriter, TextReader, TextWriter

Nuget: Install-Package Thinktecture.IO.Abstractions

Thinktecture.Text.Encoding.Abstractions

Provides interfaces for types in System.Text.Encoding: Encoding, Encoder, Decoder

Nuget: Install-Package Thinktecture.Text.Encoding.Abstractions

Thinktecture.Runtime.Extensions.Abstractions

Provides interfaces for type in System.Runtime.Extensions: Path, BitConverter, Convert, Environment, Math, Random, UriBuilder, Stopwatch, WebUtility

Nuget: Install-Package Thinktecture.Runtime.Extensions.Abstractions

Thinktecture.Runtime.Handles.Abstractions

Provides interfaces for types in System.Runtime.Handles: SafeHandle, SafeWaitHandle

Nuget: Install-Package Thinktecture.Runtime.Handles.Abstractions

Thinktecture.Runtime.Abstractions

Provides interfaces for types in System.Runtime: StringBuilder, EventArgs, statics of Guid (like Guid.NewGuid()), statics of DateTime (like DateTime.Now).

Nuget: Install-Package Thinktecture.Runtime.Abstractions

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].