-
Notifications
You must be signed in to change notification settings - Fork 309
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
1 parent
0d26cdd
commit 9cfd241
Showing
14 changed files
with
548 additions
and
548 deletions.
There are no files selected for viewing
100 changes: 50 additions & 50 deletions
100
CSharpFunctionalExtensions.Tests/MaybeTests/Extensions/MapTests.Task.Left.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,50 +1,50 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task_Left : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_Left_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Left_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Left_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe | ||
.AsTask() | ||
.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value; | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task_Left : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_Left_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Left_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Left_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe | ||
.AsTask() | ||
.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value; | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} |
96 changes: 48 additions & 48 deletions
96
CSharpFunctionalExtensions.Tests/MaybeTests/Extensions/MapTests.Task.Right.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,48 +1,48 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task_Right : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_Right_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.Map(ExpectAndReturn_Task(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Right_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.Map(ExpectAndReturn_Task(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Right_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value.AsTask(); | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task_Right : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_Right_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.Map(ExpectAndReturn_Task(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Right_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.Map(ExpectAndReturn_Task(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_Right_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value.AsTask(); | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} |
100 changes: 50 additions & 50 deletions
100
CSharpFunctionalExtensions.Tests/MaybeTests/Extensions/MapTests.Task.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,50 +1,50 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn_Task(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn_Task(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe | ||
.AsTask() | ||
.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value.AsTask(); | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace CSharpFunctionalExtensions.Tests.MaybeTests.Extensions | ||
{ | ||
public class MapTests_Task : MaybeTestBase | ||
{ | ||
[Fact] | ||
public async Task Map_Task_returns_mapped_value() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn_Task(T.Value, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
maybe2.Value.Should().Be(T.Value2); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_returns_no_value_if_initial_maybe_is_null() | ||
{ | ||
Maybe<T> maybe = null; | ||
|
||
var maybe2 = await maybe.AsTask().Map(ExpectAndReturn_Task(null, T.Value2)); | ||
|
||
maybe2.HasValue.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public async Task Map_Task_provides_context_to_selector() | ||
{ | ||
Maybe<T> maybe = T.Value; | ||
var context = 5; | ||
|
||
var maybe2 = await maybe | ||
.AsTask() | ||
.Map( | ||
(value, ctx) => | ||
{ | ||
ctx.Should().Be(context); | ||
return value.AsTask(); | ||
}, | ||
context | ||
); | ||
|
||
maybe2.HasValue.Should().BeTrue(); | ||
} | ||
} | ||
} |
Oops, something went wrong.