-
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.
Merge pull request #70 from pfpack/feature/FuncInterfaces_InitialCreate
Feature/func interfaces initial create
- Loading branch information
Showing
141 changed files
with
2,839 additions
and
1 deletion.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/core-func-factory/Fanc.Factory.Tests/Fanc.Factory.Tests.csproj
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<IsPackable>false</IsPackable> | ||
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors> | ||
<Description>PrimeFuncPack: A Functional Programming Pack for .NET</Description> | ||
<Copyright>Copyright © 2020 Andrei Sergeev, Pavel Moskovoy</Copyright> | ||
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace> | ||
<AssemblyName>PrimeFuncPack.Core.Func.Factory.Tests</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" /> | ||
<PackageReference Include="PrimeFuncPack.Core.Func.Factory" Version="*-*" /> | ||
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="2.0.*" /> | ||
<PackageReference Include="xunit" Version="2.*" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.*"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="1.*"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
42 changes: 42 additions & 0 deletions
42
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.00.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,42 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_00_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<CancellationToken, ValueTask<StructType>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null, false)] | ||
[InlineData(null, true)] | ||
[InlineData(EmptyString, false)] | ||
[InlineData(EmptyString, true)] | ||
[InlineData(WhiteSpaceString, false)] | ||
[InlineData(WhiteSpaceString, true)] | ||
[InlineData(SomeString, false)] | ||
[InlineData(SomeString, true)] | ||
public async Task Create_00_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
string? sourceFuncResult, bool canceled) | ||
{ | ||
var actual = Func.Create(_ => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: canceled); | ||
var actualResult = await actual.InvokeAsync(cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.01.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,35 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_01_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<StructType?, CancellationToken, ValueTask<RefType>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.RecordTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_01_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
RecordType? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<RefType, RecordType?>((_, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = default(CancellationToken); | ||
var actualResult = await actual.InvokeAsync(PlusFifteenIdRefType, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.02.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_02_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RefType?, RecordType, CancellationToken, ValueTask<StructType>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public async Task Create_02_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
bool? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<RecordType?, StructType, bool?>( | ||
(_, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: true); | ||
var actualResult = await actual.InvokeAsync(MinusFifteenIdNullNameRecord, default, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.03.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_03_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RecordType?, StructType, string, CancellationToken, ValueTask<RefType?>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.StructTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_03_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
StructType sourceFuncResult) | ||
{ | ||
var actual = Func.Create<string?, RefType, RecordType?, StructType>( | ||
(_, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: false); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
LowerSomeString, ZeroIdRefType, PlusFifteenIdLowerSomeStringNameRecord, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.04.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_04_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RefType?, string, RecordType, StructType, CancellationToken, ValueTask<Guid>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.RefTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_04_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
RefType? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<object, int, RecordType?, StructType, RefType?>( | ||
(_, _, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: true); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
new object(), MinusFifteen, PlusFifteenIdLowerSomeStringNameRecord, default, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.05.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_05_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RefType?, object, Guid, StructType, RecordType, CancellationToken, ValueTask<string?>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.StructTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_05_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
StructType sourceFuncResult) | ||
{ | ||
var actual = Func.Create<int?, RecordType, RefType?, string, object, StructType>( | ||
(_, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: false); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
MinusFifteen, PlusFifteenIdSomeStringNameRecord, null, SomeString, new(), cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.06.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,43 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_06_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RefType?, StructType, string, RecordType?, DateTimeKind, object, CancellationToken, ValueTask<RecordType>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData(EmptyString)] | ||
[InlineData(WhiteSpaceString)] | ||
[InlineData(TabString)] | ||
[InlineData(LowerSomeString)] | ||
[InlineData(SomeString)] | ||
public async Task Create_06_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
string? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<RefType, string, StructType?, object, RecordType, int, string?>( | ||
(_, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
MinusFifteenIdRefType, null!, new(), new(), PlusFifteenIdLowerSomeStringNameRecord, int.MaxValue, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.07.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_07_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<RecordType, string, RefType?, object, Guid?, int, StructType, CancellationToken, ValueTask<int>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.RecordTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_07_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
RecordType? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<string?, int, RefType?, object, RecordType, string, StructType, RecordType?>( | ||
(_, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: true); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
SomeString, PlusFifteen, MinusFifteenIdRefType, SomeTextStructType, null!, EmptyString, LowerSomeTextStructType, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/core-func-factory/Fanc.Factory.Tests/Test.AsyncFunc/AsyncFuncTest.08.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,38 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using PrimeFuncPack.UnitTest; | ||
using Xunit; | ||
using static PrimeFuncPack.UnitTest.TestData; | ||
|
||
namespace PrimeFuncPack.Core.Tests | ||
{ | ||
partial class AsyncFuncTest | ||
{ | ||
[Fact] | ||
public void Create_08_SourceFuncIsNull_ExpectArgumentNullException() | ||
{ | ||
var sourceFunc = (Func<DateTimeOffset, object, RefType?, Guid, RecordType, StructType?, string, long, CancellationToken, ValueTask<RecordType?>>)null!; | ||
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc)); | ||
Assert.Equal("func", ex.ParamName); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestEntitySource.RefTypes), MemberType = typeof(TestEntitySource))] | ||
public async Task Create_08_ThenInvokeAsync_ExpectResultOfSourceFunc( | ||
RefType? sourceFuncResult) | ||
{ | ||
var actual = Func.Create<object, RefType?, DateTimeKind, RecordType, int, string, StructType, RecordType, RefType?>( | ||
(_, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult)); | ||
|
||
var cancellationToken = new CancellationToken(canceled: false); | ||
|
||
var actualResult = await actual.InvokeAsync( | ||
new { Id = PlusFifteen }, default, DateTimeKind.Local, PlusFifteenIdLowerSomeStringNameRecord, MinusFifteen, null!, SomeTextStructType, MinusFifteenIdSomeStringNameRecord, cancellationToken); | ||
|
||
Assert.Equal(sourceFuncResult, actualResult); | ||
} | ||
} | ||
} |
Oops, something went wrong.