-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added static methods for abstractions (from error and from value), ad…
…ded unit tests
- Loading branch information
1 parent
43d9d3f
commit 1d60f24
Showing
4 changed files
with
63 additions
and
5 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
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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace RailwayResult.Tests; | ||
|
||
public sealed class ResultCreation_Tests | ||
{ | ||
[Fact] | ||
public void Result_FromError_Should_ReturnSameResult_AsCtor() | ||
{ | ||
//arrange | ||
var expectedResult = new Result(GenericError.ErrorA); | ||
|
||
//act | ||
var result = Result.FromError(GenericError.ErrorA); | ||
|
||
//assert | ||
result.IsSuccess.Should().Be(expectedResult.IsSuccess); | ||
result.Error.Should().BeEquivalentTo(expectedResult.Error); | ||
} | ||
|
||
[Fact] | ||
public void GenericResult_FromError_Should_ReturnSameResult_AsCtor() | ||
{ | ||
//arrange | ||
var expectedResult = new Result<string>(GenericError.ErrorA); | ||
|
||
//act | ||
var result = Result<string>.FromError(GenericError.ErrorA); | ||
|
||
//assert | ||
result.IsSuccess.Should().Be(expectedResult.IsSuccess); | ||
result.Error.Should().BeEquivalentTo(expectedResult.Error); | ||
} | ||
|
||
[Fact] | ||
public void GenericResult_FromValue_Should_ReturnSameResult_AsCtor() | ||
{ | ||
//arrange | ||
var expectedResult = Result<string>.Success("100"); | ||
|
||
//act | ||
var result = Result<string>.FromValue("100"); | ||
|
||
//assert | ||
result.IsSuccess.Should().Be(expectedResult.IsSuccess); | ||
result.Value.Should().BeEquivalentTo(expectedResult.Value); | ||
} | ||
} |