Skip to content

Commit

Permalink
Merge pull request #73 from pfpack/feature/FuncInterfaces_InitialCreate
Browse files Browse the repository at this point in the history
Rename Func.Factory to Func.Extensions
  • Loading branch information
andreise authored Feb 12, 2021
2 parents 7d6355b + 4dc22a1 commit faff33e
Show file tree
Hide file tree
Showing 106 changed files with 171 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<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>
<AssemblyName>PrimeFuncPack.Core.Func.Extensions.Tests</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.*" />
<PackageReference Include="PrimeFuncPack.Core.Func.Factory" Version="*-*" />
<PackageReference Include="PrimeFuncPack.Core.Func.Extensions" Version="*-*" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="2.0.*" />
<PackageReference Include="xunit" Version="2.*" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.*">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_00_SourceFuncIsNull_ExpectArgumentNullException()
public void From_00_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<CancellationToken, ValueTask<StructType>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

Expand All @@ -28,10 +28,10 @@ public void Create_00_SourceFuncIsNull_ExpectArgumentNullException()
[InlineData(WhiteSpaceString, true)]
[InlineData(SomeString, false)]
[InlineData(SomeString, true)]
public async Task Create_00_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_00_ThenInvokeAsync_ExpectResultOfSourceFunc(
string? sourceFuncResult, bool canceled)
{
var actual = Func.Create(_ => ValueTask.FromResult(sourceFuncResult));
var actual = Func.From(_ => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: canceled);
var actualResult = await actual.InvokeAsync(cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_01_SourceFuncIsNull_ExpectArgumentNullException()
public void From_01_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<StructType?, CancellationToken, ValueTask<RefType>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RecordTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_01_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_01_ThenInvokeAsync_ExpectResultOfSourceFunc(
RecordType? sourceFuncResult)
{
var actual = Func.Create<RefType, RecordType?>((_, _) => ValueTask.FromResult(sourceFuncResult));
var actual = Func.From<RefType, RecordType?>((_, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = default(CancellationToken);
var actualResult = await actual.InvokeAsync(PlusFifteenIdRefType, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_02_SourceFuncIsNull_ExpectArgumentNullException()
public void From_02_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RefType?, RecordType, CancellationToken, ValueTask<StructType>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[InlineData(null)]
[InlineData(true)]
[InlineData(false)]
public async Task Create_02_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_02_ThenInvokeAsync_ExpectResultOfSourceFunc(
bool? sourceFuncResult)
{
var actual = Func.Create<RecordType?, StructType, bool?>(
var actual = Func.From<RecordType?, StructType, bool?>(
(_, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_03_SourceFuncIsNull_ExpectArgumentNullException()
public void From_03_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RecordType?, StructType, string, CancellationToken, ValueTask<RefType?>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.StructTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_03_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_03_ThenInvokeAsync_ExpectResultOfSourceFunc(
StructType sourceFuncResult)
{
var actual = Func.Create<string?, RefType, RecordType?, StructType>(
var actual = Func.From<string?, RefType, RecordType?, StructType>(
(_, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_04_SourceFuncIsNull_ExpectArgumentNullException()
public void From_04_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RefType?, string, RecordType, StructType, CancellationToken, ValueTask<Guid>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RefTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_04_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_04_ThenInvokeAsync_ExpectResultOfSourceFunc(
RefType? sourceFuncResult)
{
var actual = Func.Create<object, int, RecordType?, StructType, RefType?>(
var actual = Func.From<object, int, RecordType?, StructType, RefType?>(
(_, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_05_SourceFuncIsNull_ExpectArgumentNullException()
public void From_05_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RefType?, object, Guid, StructType, RecordType, CancellationToken, ValueTask<string?>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.StructTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_05_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_05_ThenInvokeAsync_ExpectResultOfSourceFunc(
StructType sourceFuncResult)
{
var actual = Func.Create<int?, RecordType, RefType?, string, object, StructType>(
var actual = Func.From<int?, RecordType, RefType?, string, object, StructType>(
(_, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_06_SourceFuncIsNull_ExpectArgumentNullException()
public void From_06_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RefType?, StructType, string, RecordType?, DateTimeKind, object, CancellationToken, ValueTask<RecordType>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

Expand All @@ -26,10 +26,10 @@ public void Create_06_SourceFuncIsNull_ExpectArgumentNullException()
[InlineData(TabString)]
[InlineData(LowerSomeString)]
[InlineData(SomeString)]
public async Task Create_06_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_06_ThenInvokeAsync_ExpectResultOfSourceFunc(
string? sourceFuncResult)
{
var actual = Func.Create<RefType, string, StructType?, object, RecordType, int, string?>(
var actual = Func.From<RefType, string, StructType?, object, RecordType, int, string?>(
(_, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_07_SourceFuncIsNull_ExpectArgumentNullException()
public void From_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));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RecordTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_07_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_07_ThenInvokeAsync_ExpectResultOfSourceFunc(
RecordType? sourceFuncResult)
{
var actual = Func.Create<string?, int, RefType?, object, RecordType, string, StructType, RecordType?>(
var actual = Func.From<string?, int, RefType?, object, RecordType, string, StructType, RecordType?>(
(_, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_08_SourceFuncIsNull_ExpectArgumentNullException()
public void From_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));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RefTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_08_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_08_ThenInvokeAsync_ExpectResultOfSourceFunc(
RefType? sourceFuncResult)
{
var actual = Func.Create<object, RefType?, DateTimeKind, RecordType, int, string, StructType, RecordType, RefType?>(
var actual = Func.From<object, RefType?, DateTimeKind, RecordType, int, string, StructType, RecordType, RefType?>(
(_, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_09_SourceFuncIsNull_ExpectArgumentNullException()
public void From_09_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<long, RefType?, StructType, RecordType, DateTimeOffset, int?, RecordType?, object?, RefType, CancellationToken, ValueTask<object?>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.StructTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_09_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_09_ThenInvokeAsync_ExpectResultOfSourceFunc(
StructType sourceFuncResult)
{
var actual = Func.Create<RecordType, RefType, int, object?, StructType, string, RecordType?, string?, RefType?, StructType>(
var actual = Func.From<RecordType, RefType, int, object?, StructType, string, RecordType?, string?, RefType?, StructType>(
(_, _, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_10_SourceFuncIsNull_ExpectArgumentNullException()
public void From_10_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RecordType?, object, string, DateTime?, int, StructType, long, RefType?, StructType?, RecordType, CancellationToken, ValueTask<string>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

Expand All @@ -25,10 +25,10 @@ public void Create_10_SourceFuncIsNull_ExpectArgumentNullException()
[InlineData(MinusFifteen)]
[InlineData(PlusFifteen)]
[InlineData(int.MaxValue)]
public async Task Create_10_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_10_ThenInvokeAsync_ExpectResultOfSourceFunc(
int? sourceFuncResult)
{
var actual = Func.Create<object?, StructType?, RefType?, RecordType?, int, string?, long, int?, RefType, StructType?, int?>(
var actual = Func.From<object?, StructType?, RefType?, RecordType?, int, string?, long, int?, RefType, StructType?, int?>(
(_, _, _, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = default(CancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_11_SourceFuncIsNull_ExpectArgumentNullException()
public void From_11_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<RecordType?, string, StructType, long?, object, DateTimeKind, RefType?, decimal, object, RecordType, byte, CancellationToken, ValueTask<DateTime>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RefTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_11_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_11_ThenInvokeAsync_ExpectResultOfSourceFunc(
RefType? sourceFuncResult)
{
var actual = Func.Create<StructType, RefType?, long, string, RefType, object, long, DateTimeKind, RefType, object, StructType?, RefType?>(
var actual = Func.From<StructType, RefType?, long, string, RefType, object, long, DateTimeKind, RefType, object, StructType?, RefType?>(
(_, _, _, _, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ namespace PrimeFuncPack.Core.Tests
partial class AsyncFuncTest
{
[Fact]
public void Create_12_SourceFuncIsNull_ExpectArgumentNullException()
public void From_12_SourceFuncIsNull_ExpectArgumentNullException()
{
var sourceFunc = (Func<string, int, decimal?, object?, RefType, StructType?, DateTime?, RecordType, int, StructType, object?, string?, CancellationToken, ValueTask<RefType?>>)null!;
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.Create(sourceFunc));
var ex = Assert.Throws<ArgumentNullException>(() => _ = Func.From(sourceFunc));
Assert.Equal("funcAsync", ex.ParamName);
}

[Theory]
[MemberData(nameof(TestEntitySource.RecordTypes), MemberType = typeof(TestEntitySource))]
public async Task Create_12_ThenInvokeAsync_ExpectResultOfSourceFunc(
public async Task From_12_ThenInvokeAsync_ExpectResultOfSourceFunc(
RecordType? sourceFuncResult)
{
var actual = Func.Create<int, object, RecordType?, RefType, object, string?, string, decimal, byte, RecordType, StructType, object, RecordType?>(
var actual = Func.From<int, object, RecordType?, RefType, object, string?, string, decimal, byte, RecordType, StructType, object, RecordType?>(
(_, _, _, _, _, _, _, _, _, _, _, _, _) => ValueTask.FromResult(sourceFuncResult));

var cancellationToken = new CancellationToken(canceled: true);
Expand Down
Loading

0 comments on commit faff33e

Please sign in to comment.