diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 49e60974..b83cb3a7 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -4,6 +4,8 @@ on: # PRs will be built, and a package posted to GH Packages pull_request: + workflow_dispatch: + push: paths-ignore: - 'README.md' @@ -30,9 +32,14 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v4 - # Run unit tests + - name: NuGet restore + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test - run: dotnet test --configuration Release --verbosity normal + run: dotnet test --configuration Release --no-build --verbosity normal # Package Release - name: Pack diff --git a/Directory.Build.props b/Directory.Build.props index 82dc6821..66820c8f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 10.0 + 12.0 enable enable true diff --git a/Moq.AutoMock.Tests/DescribeCreateInstance.cs b/Moq.AutoMock.Tests/DescribeCreateInstance.cs index 1d377f40..a31f135b 100644 --- a/Moq.AutoMock.Tests/DescribeCreateInstance.cs +++ b/Moq.AutoMock.Tests/DescribeCreateInstance.cs @@ -226,6 +226,16 @@ public void It_can_create_instances_of_nested_sealed_classes() Assert.AreEqual(mockWithSealedService.SealedService, mockWithSealedService.NestedSealedService.SealedService); } + [TestMethod] + public void It_can_create_instance_of_class_with_primary_constructor() + { + AutoMocker mocker = new(); + + PrimaryConstructor instance = mocker.CreateInstance(); + + Assert.IsInstanceOfType(instance.Service, typeof(IService1)); + } + private class CustomStringResolver : IMockResolver { public CustomStringResolver(string stringValue) diff --git a/Moq.AutoMock.Tests/Util/PrimaryConstructor.cs b/Moq.AutoMock.Tests/Util/PrimaryConstructor.cs new file mode 100644 index 00000000..27cdb041 --- /dev/null +++ b/Moq.AutoMock.Tests/Util/PrimaryConstructor.cs @@ -0,0 +1,9 @@ +using System.Diagnostics.CodeAnalysis; + +namespace Moq.AutoMock.Tests.Util; + +[ExcludeFromCodeCoverage] +public class PrimaryConstructor(IService1 service) +{ + public IService1 Service { get; set; } = service; +} \ No newline at end of file diff --git a/global.json b/global.json index a071fad8..bc54e196 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.400", + "version": "8.0.100", "rollForward": "latestMinor" } } \ No newline at end of file