VOOZH about

URL: https://www.nuget.org/packages/FluentResult.FluentAssertions/

⇱ NuGet Gallery | FluentResult.FluentAssertions 0.1.0




👁 Image
FluentResult.FluentAssertions 0.1.0

dotnet add package FluentResult.FluentAssertions --version 0.1.0
 
 
NuGet\Install-Package FluentResult.FluentAssertions -Version 0.1.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FluentResult.FluentAssertions" Version="0.1.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentResult.FluentAssertions" Version="0.1.0" />
 
Directory.Packages.props
<PackageReference Include="FluentResult.FluentAssertions" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FluentResult.FluentAssertions --version 0.1.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FluentResult.FluentAssertions, 0.1.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FluentResult.FluentAssertions@0.1.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FluentResult.FluentAssertions&version=0.1.0
 
Install as a Cake Addin
#tool nuget:?package=FluentResult.FluentAssertions&version=0.1.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

FluentResult

FluentResult is a C# library that provides a fluent API for handling results of operations, including success and failure cases. It includes various utilities and extensions to simplify error handling and result aggregation.

Table of Contents

Installation

To install FluentResult, you can use the NuGet package manager:

dotnet add package FluentResult

Usage

Basic Result Handling

You can create and handle results using the Result class and its extension methods.

using DrifterApps.Seeds.FluentResult;

// Creating a success result
var successResult = Result<int>.Success(42);

// Creating a failure result
var failureResult = Result<int>.Failure(new ResultError("Error.Code", "Error description"));

// Handling success and failure
var finalResult = successResult.OnSuccess(value => Result<string>.Success(value.ToString()))
 .OnFailure(error => Result<string>.Failure(error));

Aggregating Results

You can aggregate multiple results using the ResultAggregate class.

using DrifterApps.Seeds.FluentResult;

var resultAggregate = ResultAggregate.Create();
var successResult = Result<Nothing>.Success();
var failureResult = Result<Nothing>.Failure(new ResultError("Error.Code", "Error description"));

resultAggregate.AddResult(successResult);
resultAggregate.AddResult(failureResult);

bool isSuccess = resultAggregate.IsSuccess; // false
bool isFailure = resultAggregate.IsFailure; // true

Asynchronous Result Handling

You can handle results asynchronously using the extension methods provided in ResultExtensions.Async.

using DrifterApps.Seeds.FluentResult;

var resultTask = Task.FromResult(Result<int>.Success(42));

var finalResult = await resultTask.OnSuccess(async value => await Task.FromResult(Result<string>.Success(value.ToString())))
 .OnFailure(async error => await Task.FromResult(Result<string>.Failure(error)));

Ensuring Validation

You can ensure that a specific validation function returns true using the Ensure method. If the validation fails, it adds a failure result to the source.

using DrifterApps.Seeds.FluentResult;

var aggregate = ResultAggregate.Create();
aggregate.AddResult(Result<Nothing>.Failure(new ResultError("Error.Code", "Initial error")));

// Ensure validation with IgnoreOnFailure option
var result = aggregate.Ensure(() => true, new ResultError("Validation.Error", "Validation failed"), EnsureOnFailure.IgnoreOnFailure);

// Ensure validation with default ValidateOnFailure option
var resultWithValidation = aggregate.Ensure(() => false, new ResultError("Validation.Error", "Validation failed"));

bool isSuccess = result.IsSuccess; // true
bool isFailure = result.IsFailure; // false

bool isValidationSuccess = resultWithValidation.IsSuccess; // false
bool isValidationFailure = resultWithValidation.IsFailure; // true

Contributing

Contributions are welcome! Please read the contributing guidelines for more information.

License

This project is licensed under the MIT License. See the file for details.

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 296 10/18/2024 0.1.0 is deprecated because it is no longer maintained.