Skip to content

Archway-SharedLib/Nut.Results

Repository files navigation

logo

CI codecov

Nut.Results

NuGet NuGet

Nut.Results provides an object in .NET that represents the result of a simple process, and can represent the success or failure of the process.

What does it solve

Processing failures are usually represented by exceptions or boolean values, sometimes null. This way of returning the result of processing has the following problems.

  • The use of exceptions results in a non-linear flow of processing, which reduces the parsability and readability of the code, and increases the difficulty of maintenance.
  • When using boolean values, the details of the processing result will be lost.
  • When null is used, it is not possible to indicate whether the value null represents a failure or simply the absence of a result (for example, there was no data in the data acquisition process). The developer needs to be aware of this for each process, which can cause problems.

Using Nut.Results for processing results solves the above problem.

var okResult = Result.Ok("The process was successful!");

For detailed instructions, see documentation. You can check how to use it through refactoring. For the API provided, see API documentation.

Nut.Results.FluentAssertions

NuGet NuGet

Nut.Results.FluentAssertions is an extension library of FluentAssertions. It provides methods for validating Result objects.

var result = Result.Ok();
result.Should().BeOk();

For detailed instructions, see documentation.