-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
262 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 30 additions & 30 deletions
60
...ate4dTrain.Functional.Result.Tests.csproj → ...ult.Tests/Late4dTrain.Result.Tests.csproj
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<RootNamespace>Late4dTrain.Functional.ResultTests</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.3.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Late4dTrain.Functional.Result\Late4dTrain.Functional.Result.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<RootNamespace>Late4dTrain</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.3.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Late4dTrain.Result\Late4dTrain.Result.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
122 changes: 61 additions & 61 deletions
122
...in.Functional.Result.Tests/OnFailTests.cs → Late4dTrain.Result.Tests/OnFailTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
namespace Late4dTrain.Functional.ResultTests; | ||
|
||
using System; | ||
|
||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
public class OnFailTests | ||
{ | ||
[Fact] | ||
public void OnFailWithIntResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedError = string.Empty; | ||
|
||
var result = Result<string>.Fail<int>("It went wrong..."); | ||
var func = () => result.Value; | ||
|
||
result | ||
.OnSuccess((i) => successCalled = true) | ||
.OnFailure((e) => | ||
{ | ||
failCalled = true; | ||
capturedError = e; | ||
} | ||
); | ||
|
||
successCalled.Should().BeFalse(); | ||
failCalled.Should().BeTrue(); | ||
result.Error.Should().Be("It went wrong..."); | ||
capturedError.Should().Be("It went wrong..."); | ||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
|
||
[Fact] | ||
public void OnFailWithoutResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedError = string.Empty; | ||
|
||
var result = Result<string>.Fail("It went wrong..."); | ||
|
||
result | ||
.OnSuccess(() => successCalled = true) | ||
.OnFailure((e) => | ||
{ | ||
failCalled = true; | ||
capturedError = e; | ||
} | ||
); | ||
|
||
successCalled.Should().BeFalse(); | ||
failCalled.Should().BeTrue(); | ||
result.Error.Should().Be("It went wrong..."); | ||
capturedError.Should().Be("It went wrong..."); | ||
} | ||
|
||
} | ||
namespace Late4dTrain; | ||
|
||
using System; | ||
|
||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
public class OnFailTests | ||
{ | ||
[Fact] | ||
public void OnFailWithIntResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedError = string.Empty; | ||
|
||
var result = Result<string>.Fail<int>("It went wrong..."); | ||
var func = () => result.Value; | ||
|
||
result | ||
.OnSuccess((i) => successCalled = true) | ||
.OnFailure((e) => | ||
{ | ||
failCalled = true; | ||
capturedError = e; | ||
} | ||
); | ||
|
||
successCalled.Should().BeFalse(); | ||
failCalled.Should().BeTrue(); | ||
result.Error.Should().Be("It went wrong..."); | ||
capturedError.Should().Be("It went wrong..."); | ||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
|
||
[Fact] | ||
public void OnFailWithoutResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedError = string.Empty; | ||
|
||
var result = Result<string>.Fail("It went wrong..."); | ||
|
||
result | ||
.OnSuccess(() => successCalled = true) | ||
.OnFailure((e) => | ||
{ | ||
failCalled = true; | ||
capturedError = e; | ||
} | ||
); | ||
|
||
successCalled.Should().BeFalse(); | ||
failCalled.Should().BeTrue(); | ||
result.Error.Should().Be("It went wrong..."); | ||
capturedError.Should().Be("It went wrong..."); | ||
} | ||
|
||
} |
110 changes: 55 additions & 55 deletions
110
...Functional.Result.Tests/OnSuccessTests.cs → Late4dTrain.Result.Tests/OnSuccessTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
namespace Late4dTrain.Functional.ResultTests; | ||
|
||
using System; | ||
|
||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
public class OnSuccessTests | ||
{ | ||
[Fact] | ||
public void OnSuccessWithIntResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedResult = 0; | ||
|
||
var result = Result<string>.Ok(42); | ||
var func = () => result.Error; | ||
|
||
result | ||
.OnSuccess((i) => | ||
{ | ||
successCalled = true; | ||
capturedResult = i; | ||
} | ||
) | ||
.OnFailure((e) => failCalled = true); | ||
|
||
successCalled.Should().BeTrue(); | ||
failCalled.Should().BeFalse(); | ||
result.Value.Should().Be(42); | ||
capturedResult.Should().Be(42); | ||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
|
||
[Fact] | ||
public void OnSuccessWithoutResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
|
||
var result = Result<string>.Ok(); | ||
var func = () => result.Error; | ||
|
||
result | ||
.OnSuccess(() => successCalled = true) | ||
.OnFailure((e) => failCalled = true); | ||
|
||
successCalled.Should().BeTrue(); | ||
failCalled.Should().BeFalse(); | ||
|
||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
} | ||
namespace Late4dTrain; | ||
|
||
using System; | ||
|
||
using FluentAssertions; | ||
|
||
using Xunit; | ||
|
||
public class OnSuccessTests | ||
{ | ||
[Fact] | ||
public void OnSuccessWithIntResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
var capturedResult = 0; | ||
|
||
var result = Result<string>.Ok(42); | ||
var func = () => result.Error; | ||
|
||
result | ||
.OnSuccess((i) => | ||
{ | ||
successCalled = true; | ||
capturedResult = i; | ||
} | ||
) | ||
.OnFailure((e) => failCalled = true); | ||
|
||
successCalled.Should().BeTrue(); | ||
failCalled.Should().BeFalse(); | ||
result.Value.Should().Be(42); | ||
capturedResult.Should().Be(42); | ||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
|
||
[Fact] | ||
public void OnSuccessWithoutResult() | ||
{ | ||
var successCalled = false; | ||
var failCalled = false; | ||
|
||
var result = Result<string>.Ok(); | ||
var func = () => result.Error; | ||
|
||
result | ||
.OnSuccess(() => successCalled = true) | ||
.OnFailure((e) => failCalled = true); | ||
|
||
successCalled.Should().BeTrue(); | ||
failCalled.Should().BeFalse(); | ||
|
||
func.Should().Throw<InvalidOperationException>(); | ||
} | ||
} |
44 changes: 22 additions & 22 deletions
44
Late4dTrain.Functional.sln → Late4dTrain.Result.sln
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Late4dTrain.Functional.Result", "Late4dTrain.Functional.Result\Late4dTrain.Functional.Result.csproj", "{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Late4dTrain.Functional.Result.Tests", "Late4dTrain.Functional.Result.Tests\Late4dTrain.Functional.Result.Tests.csproj", "{4AF544CA-A934-4853-911A-DB9E481CA52B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Late4dTrain.Result", "Late4dTrain.Result\Late4dTrain.Result.csproj", "{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Late4dTrain.Result.Tests", "Late4dTrain.Result.Tests\Late4dTrain.Result.Tests.csproj", "{4AF544CA-A934-4853-911A-DB9E481CA52B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AD4BBABF-A9D3-4880-895C-9F7CAEC8EB4F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4AF544CA-A934-4853-911A-DB9E481CA52B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.