generated from goatcorp/SamplePlugin
-
Notifications
You must be signed in to change notification settings - Fork 4
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
7 changed files
with
213 additions
and
51 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
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
91 changes: 91 additions & 0 deletions
91
ScoutHelperTests/Utils/Functional/FunctionalExtensionsTest.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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using CSharpFunctionalExtensions; | ||
using FluentAssertions; | ||
using FsCheck; | ||
using FsCheck.Xunit; | ||
using JetBrains.Annotations; | ||
using ScoutHelper; | ||
using ScoutHelper.Utils.Functional; | ||
using ScoutHelperTests.TestUtils.FsCheck; | ||
using static ScoutHelperTests.TestUtils.FsCheck.FsCheckUtils; | ||
|
||
namespace ScoutHelperTests.Utils.Functional; | ||
|
||
[TestSubject(typeof(FunctionalExtensions))] | ||
public class FunctionalExtensionsTest { | ||
[Property] | ||
public Property MaybeGet_MissingKey() => ForAll( | ||
Arbs.String().DictWith(Arbs.String()), | ||
Arbs.String(), | ||
(arbitraryDict, lookupKey) => { | ||
// DATA | ||
var dict = arbitraryDict.Without(lookupKey); | ||
// WHEN | ||
var actual = dict.MaybeGet(lookupKey); | ||
// THEN | ||
actual.Should().Be(Maybe<string>.None); | ||
} | ||
); | ||
|
||
[Property] | ||
public Property MaybeGet_ContainsKey() => ForAll( | ||
Arbs.String().DictWith(Arbs.String()), | ||
Arbs.String(), | ||
Arbs.String(), | ||
(arbitraryDict, lookupKey, lookupValue) => { | ||
// DATA | ||
var dict = arbitraryDict.With((lookupKey, lookupValue)); | ||
// WHEN | ||
var actual = dict.MaybeGet(lookupKey); | ||
// THEN | ||
actual.Should().Be(Maybe.From(lookupValue)); | ||
} | ||
); | ||
|
||
[Property] | ||
public Property MaybeGet_EmptyDict() => ForAll( | ||
Arbs.String(), | ||
lookupKey => { | ||
// DATA | ||
var dict = new Dictionary<string, string>(); | ||
// WHEN | ||
var actual = dict.MaybeGet(lookupKey); | ||
// THEN | ||
actual.Should().Be(Maybe<string>.None); | ||
} | ||
); | ||
|
||
[Property] | ||
public Property SelectMaybe_ExistingList() => ForAll( | ||
Arbs.String().ToMaybeArb().NonEmptyListOf(), | ||
(list) => { | ||
// DATA | ||
var expectedValues = list | ||
.Where(maybe => !Maybe<string>.None.Equals(maybe)) | ||
.Select(value => value.Value); | ||
// WHEN | ||
var actual = list.SelectMaybe(); | ||
// THEN | ||
actual.Should().BeEquivalentTo(expectedValues); | ||
} | ||
); | ||
|
||
// select maybe | ||
// reduce | ||
|
||
// == result == | ||
// as pair | ||
// for each error | ||
// join | ||
// select results | ||
// select values | ||
// to accresult | ||
// with value | ||
} |