Skip to content

Commit

Permalink
Merge pull request #16 from pfpack/release/v2.2.0-preview.1
Browse files Browse the repository at this point in the history
release/v2.2.0-preview.1
  • Loading branch information
andreise authored Mar 3, 2023
2 parents f593a3a + 8e3ebf2 commit e24a6e5
Show file tree
Hide file tree
Showing 115 changed files with 3,893 additions and 65 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: .NET

on:
push:
branches: [ main, dev, dev/*, feature/*, fix/*, release/* ]
branches: [ main, dev, feature/*, fix/*, release/* ]

pull_request:
branches: [ main ]
Expand All @@ -17,12 +17,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: |
6.0.x
7.0.x
# Create Local NuGet Source

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ node_modules/
*.dsw
*.dsp

# Visual Studio 6 technical files
# Visual Studio 6 technical files
*.ncb
*.aps

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2022 Andrei Sergeev, Pavel Moskovoy
Copyright (c) 2020-2023 Andrei Sergeev, Pavel Moskovoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions src/core-unit/Unit.Tests/Unit.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<Authors>Andrei Sergeev, Pavel Moskovoy</Authors>
<Copyright>Copyright © 2020-2022 Andrei Sergeev, Pavel Moskovoy</Copyright>
<Copyright>Copyright © 2020-2023 Andrei Sergeev, Pavel Moskovoy</Copyright>
<RootNamespace>PrimeFuncPack.Core.Tests</RootNamespace>
<AssemblyName>PrimeFuncPack.Core.Unit.Tests</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Data" Version="3.0.0" />
<PackageReference Include="PrimeFuncPack.UnitTest.Moq" Version="1.0.3" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_00_FuncIsNull_ExpectArgumentNullException()
{
Func<Task> funcAsync = null!;
var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync());

Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_00_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc(Task.CompletedTask);
var funcAsync = new Func<Task>(mockFuncAsync.Object.Invoke);

var actual = await funcAsync.InvokeAsFuncAsync();

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(f => f.Invoke(), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_01_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, Task> funcAsync = null!;
var arg = SomeTextStructType;

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg));

Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
[TestCase(true)]
[TestCase(false)]
public async Task InvokeAsFuncAsync_01_ExpectCallFuncOnce(
bool isArgNull)
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<RefType?, Task>(Task.CompletedTask);
var funcAsync = new Func<RefType?, Task>(mockFuncAsync.Object.Invoke);

var arg = isArgNull ? null : MinusFifteenIdRefType;
var actual = await funcAsync.InvokeAsFuncAsync(arg);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(f => f.Invoke(arg), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_02_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, RefType, Task> funcAsync = null!;

var arg1 = SomeTextStructType;
var arg2 = PlusFifteenIdRefType;

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg1, arg2));
Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_02_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<StructType, RefType?, Task>(Task.CompletedTask);
var funcAsync = new Func<StructType, RefType?, Task>(mockFuncAsync.Object.Invoke);

var arg1 = SomeTextStructType;
var arg2 = (RefType?)null;

var actual = await funcAsync.InvokeAsFuncAsync(arg1, arg2);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(f => f.Invoke(arg1, arg2), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_03_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, RefType, string, Task> funcAsync = null!;

var arg1 = SomeTextStructType;
var arg2 = PlusFifteenIdRefType;
var arg3 = TabString;

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3));
Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_03_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<StructType, RefType?, string, Task>(Task.CompletedTask);
var funcAsync = new Func<StructType, RefType?, string, Task>(mockFuncAsync.Object.Invoke);

var arg1 = SomeTextStructType;
var arg2 = (RefType?)null;
var arg3 = TabString;

var actual = await funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(f => f.Invoke(arg1, arg2, arg3), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_04_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, RefType, string, int, Task> funcAsync = null!;

var arg1 = SomeTextStructType;
var arg2 = PlusFifteenIdRefType;
var arg3 = TabString;
var arg4 = MinusFortyFive;

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4));
Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_04_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<StructType, RefType?, string, int, Task>(Task.CompletedTask);
var funcAsync = new Func<StructType, RefType?, string, int, Task>(mockFuncAsync.Object.Invoke);

var arg1 = SomeTextStructType;
var arg2 = (RefType?)null;
var arg3 = TabString;
var arg4 = MinusFortyFive;

var actual = await funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(f => f.Invoke(arg1, arg2, arg3, arg4), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_05_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, RefType, string, int, object, Task> funcAsync = null!;

var arg1 = SomeTextStructType;
var arg2 = PlusFifteenIdRefType;
var arg3 = TabString;
var arg4 = MinusFortyFive;
var arg5 = new { Value = PlusTwoHundredPointFive };

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4, arg5));
Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_05_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<StructType, RefType?, string, int, object?, Task>(Task.CompletedTask);
var funcAsync = new Func<StructType, RefType?, string, int, object?, Task>(mockFuncAsync.Object.Invoke);

var arg1 = SomeTextStructType;
var arg2 = (RefType?)null;
var arg3 = TabString;
var arg4 = MinusFortyFive;
var arg5 = new { Value = PlusTwoHundredPointFive };

var actual = await funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4, arg5);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(a => a.Invoke(arg1, arg2, arg3, arg4, arg5), Times.Once);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Moq;
using NUnit.Framework;
using PrimeFuncPack.UnitTest;
using PrimeFuncPack.UnitTest.Moq;
using System;
using System.Threading.Tasks;
using static PrimeFuncPack.UnitTest.TestData;

namespace PrimeFuncPack.Core.Tests;

partial class UnitExtensionsInvokeAsyncTests
{
[Test]
public void InvokeAsFuncAsync_06_FuncIsNull_ExpectArgumentNullException()
{
Func<StructType, RefType, string, int, object, DateTime, Task> funcAsync = null!;

var arg1 = SomeTextStructType;
var arg2 = PlusFifteenIdRefType;
var arg3 = TabString;
var arg4 = MinusFortyFive;
var arg5 = new { Value = PlusTwoHundredPointFive };
var arg6 = Year2015March11H01Min15;

var ex = Assert.ThrowsAsync<ArgumentNullException>(() => _ = funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4, arg5, arg6));
Assert.AreEqual("funcAsync", ex!.ParamName);
}

[Test]
public async Task InvokeAsFuncAsync_06_ExpectCallFuncOnce()
{
var mockFuncAsync = MockFuncFactory.CreateMockFunc<StructType, RefType?, string, int, object?, DateTime, Task>(Task.CompletedTask);
var funcAsync = new Func<StructType, RefType?, string, int, object?, DateTime, Task>(mockFuncAsync.Object.Invoke);

var arg1 = SomeTextStructType;
var arg2 = (RefType?)null;
var arg3 = TabString;
var arg4 = MinusFortyFive;
var arg5 = new { Value = PlusTwoHundredPointFive };
var arg6 = Year2015March11H01Min15;

var actual = await funcAsync.InvokeAsFuncAsync(arg1, arg2, arg3, arg4, arg5, arg6);

Assert.AreEqual(Unit.Value, actual);
mockFuncAsync.Verify(a => a.Invoke(arg1, arg2, arg3, arg4, arg5, arg6), Times.Once);
}
}
Loading

0 comments on commit e24a6e5

Please sign in to comment.