Skip to content

Commit

Permalink
Merge pull request #6 from futurum-dev/feature/improve-README.md
Browse files Browse the repository at this point in the history
Improve README.md and Nuget version bump for Futurum.Core to 1.0.15
  • Loading branch information
futurum-dev authored Apr 7, 2023
2 parents 6061ff5 + cc1b5b3 commit 2eb1f3d
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 112 deletions.
117 changes: 115 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,121 @@
# Futurum.Test

![license](https://img.shields.io/github/license/futurum-dev/dotnet.futurum.test?style=for-the-badge)
![CI](https://img.shields.io/github/workflow/status/futurum-dev/dotnet.futurum.test/CI/main?style=for-the-badge)
![CI](https://img.shields.io/github/actions/workflow/status/futurum-dev/dotnet.futurum.test/ci.yml?branch=main&style=for-the-badge)
[![Coverage Status](https://img.shields.io/coveralls/github/futurum-dev/dotnet.futurum.test?style=for-the-badge)](https://coveralls.io/github/futurum-dev/dotnet.futurum.test?branch=main)
[![NuGet version](https://img.shields.io/nuget/v/futurum.test?style=for-the-badge)](https://www.nuget.org/packages/futurum.test)

A dotnet testing library, allowing you to test code that uses Futurum.Core
A dotnet testing library, allowing you to test code that uses Futurum.Core. It contains a comprehensive set of assertions for testing Futurum.Core types.

## Result
### ShouldBeSuccess
Checks that the result is a success.

```csharp
result.ShouldBeSuccess();
```

### ShouldBeSuccessWithValue
Checks that the result is a success and that the value is equal to the expected value.

```csharp
result.ShouldBeSuccessWithValue(expectedValue);
```

### ShouldBeSuccessWithValueEquivalentTo
Checks that the result is a success and that the value is equivalent to the expected value.

```csharp
result.ShouldBeSuccessWithValueEquivalentTo(equivalentValue);
```

### ShouldBeSuccessWithValueEquivalentToAsync
Checks that the result is a success and that the value is equivalent to the expected value.

```csharp
result.ShouldBeSuccessWithValueEquivalentToAsync(numbers);
```

**NOTE** This method works with *IAsyncEnumerable<T>*.

### ShouldBeSuccessWithValueAssertion
Checks that the result is a success and that the value passes the assertions specified.

```csharp
result.ShouldBeSuccessWithValueAssertion(x => x.Should().Be(expectedValue));
```

### ShouldBeFailure
Checks that the result is a failure.

```csharp
result.ShouldBeFailure();
```

### ShouldBeFailureWithError
Checks that the result is a failure and that the error is equal to the expected error.

```csharp
result.ShouldBeFailureWithError(expectedErrorMessage);
```

### ShouldBeFailureWithErrorSafe
Checks that the result is a failure and that the error is equal to the expected error.

```csharp
result.ShouldBeFailureWithErrorSafe(expectedErrorMessage);
```

**NOTE** This will call *ToErrorStringSafe* on the error.

### ShouldBeFailureWithErrorContaining
Checks that the result is a failure and that the error contains the expected error.

```csharp
result.ShouldBeFailureWithErrorContaining(expectedErrorMessage);
```

### ShouldBeFailureWithErrorSafeContaining
Checks that the result is a failure and that the error contains the expected error.

```csharp
result.ShouldBeFailureWithErrorContaining(expectedErrorMessage);
```

**NOTE** This will call *ToErrorStringSafe* on the error.

## Option
### ShouldBeHasValue
Check that the option has a value.

```csharp
option.ShouldBeHasValue();
```

### ShouldBeHasValueWithValue
Check that the option has a value and that the value is equal to the expected value.

```csharp
option.ShouldBeHasValueWithValue(expectedValue);
```

### ShouldBeHasValueWithValueEquivalentTo
Check that the option has a value and that the value is equivalent to the expected value.

```csharp
option.ShouldBeHasValueWithValueEquivalentTo(equivalentValue);
```

### ShouldBeHasValueWithValueAssertion
Check that the option has a value and that the value passes the assertions specified.

```csharp
option.ShouldBeHasValueWithValueAssertion(x => x.Should().Be(expectedValue));
```

### ShouldBeHasNoValue
Check that the option has no value.

```csharp
option.ShouldBeHasNoValue();
```
2 changes: 1 addition & 1 deletion src/Futurum.Test/Futurum.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Futurum.Core" Version="1.0.13" />
<PackageReference Include="Futurum.Core" Version="1.0.15" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
2 changes: 1 addition & 1 deletion test/Futurum.Test.Tests/Futurum.Test.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Futurum.Core" Version="1.0.13" />
<PackageReference Include="Futurum.Core" Version="1.0.15" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ public class ShouldBeFailure
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok();
var result = Core.Result.Result.Ok();

var action = () => option.ShouldBeFailure();
var action = () => result.ShouldBeFailure();

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail(ERROR_MESSAGE);
var result = Core.Result.Result.Fail(ERROR_MESSAGE);

option.ShouldBeFailure();
result.ShouldBeFailure();
}
}

Expand All @@ -37,19 +37,19 @@ public class ShouldBeFailureWithErrorSafe
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok();
var result = Core.Result.Result.Ok();

var action = () => option.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail(ERROR_MESSAGE);
var result = Core.Result.Result.Fail(ERROR_MESSAGE);

option.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
}
}

Expand All @@ -58,19 +58,19 @@ public class ShouldBeFailureWithError
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok();
var result = Core.Result.Result.Ok();

var action = () => option.ShouldBeFailureWithError(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithError(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail(ERROR_MESSAGE);
var result = Core.Result.Result.Fail(ERROR_MESSAGE);

option.ShouldBeFailureWithError(ERROR_MESSAGE);
result.ShouldBeFailureWithError(ERROR_MESSAGE);
}
}

Expand All @@ -79,19 +79,19 @@ public class ShouldBeFailure_Generic
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok(10);
var result = Core.Result.Result.Ok(10);

var action = () => option.ShouldBeFailure();
var action = () => result.ShouldBeFailure();

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail<int>(ERROR_MESSAGE);
var result = Core.Result.Result.Fail<int>(ERROR_MESSAGE);

option.ShouldBeFailure();
result.ShouldBeFailure();
}
}

Expand All @@ -100,19 +100,19 @@ public class ShouldBeFailureWithErrorSafe_Generic
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok(10);
var result = Core.Result.Result.Ok(10);

var action = () => option.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail<int>(ERROR_MESSAGE);
var result = Core.Result.Result.Fail<int>(ERROR_MESSAGE);

option.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorSafe(ERROR_MESSAGE);
}
}

Expand All @@ -121,19 +121,19 @@ public class ShouldBeFailureWithError_Generic
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok(10);
var result = Core.Result.Result.Ok(10);

var action = () => option.ShouldBeFailureWithError(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithError(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail<int>(ERROR_MESSAGE);
var result = Core.Result.Result.Fail<int>(ERROR_MESSAGE);

option.ShouldBeFailureWithError(ERROR_MESSAGE);
result.ShouldBeFailureWithError(ERROR_MESSAGE);
}
}

Expand All @@ -142,19 +142,19 @@ public class ShouldBeFailureWithErrorSafeContaining
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok();
var result = Core.Result.Result.Ok();

var action = () => option.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));
var result = Core.Result.Result.Fail(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));

option.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
}
}

Expand All @@ -163,19 +163,19 @@ public class ShouldBeFailureWithErrorContaining
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok();
var result = Core.Result.Result.Ok();

var action = () => option.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));
var result = Core.Result.Result.Fail(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));

option.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
}
}

Expand All @@ -184,19 +184,19 @@ public class ShouldBeFailureWithErrorSafeContaining_Generic
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok(10);
var result = Core.Result.Result.Ok(10);

var action = () => option.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail<int>(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));
var result = Core.Result.Result.Fail<int>(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));

option.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorSafeContaining(ERROR_MESSAGE);
}
}

Expand All @@ -205,19 +205,19 @@ public class ShouldBeFailureWithErrorContaining_Generic
[Fact]
public void Success()
{
var option = Core.Result.Result.Ok(10);
var result = Core.Result.Result.Ok(10);

var action = () => option.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
var action = () => result.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);

action.Should().Throw<Xunit.Sdk.XunitException>().Which.Message.Should().Contain("Expected result.IsFailure to be true, but found False.");
}

[Fact]
public void Failure()
{
var option = Core.Result.Result.Fail<int>(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));
var result = Core.Result.Result.Fail<int>(ResultErrorCompositeExtensions.ToResultError(ERROR_MESSAGE.ToResultError(), ERROR_MESSAGE.ToResultError()));

option.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
result.ShouldBeFailureWithErrorContaining(ERROR_MESSAGE);
}
}

Expand Down
Loading

0 comments on commit 2eb1f3d

Please sign in to comment.