Problem Statement
Findings
When migrating from Moq to Tunit.Mocks I encountered the following issue. Since this isn't supported yet, I made this a feature request and not a bug.
Mocking concrete Azure.Data.Tables.TableClient is not supported in Tunit but is in Moq. This complicates the migration.
For now we use Tunit.Mocks 'where possible'
Reproduction
#:property LangVersion=preview
#:property ManagePackageVersionsCentrally=false
#:package TUnit.Mocks@1.21.30
#:package Azure.Data.Tables@12.11.0
#:package Azure.Storage.Blobs@12.27.0
using Azure.Data.Tables;
using Azure.Storage.Blobs;
var tableClientMock = Mock.OfPartial<TableClient>(MockBehavior.Strict);
var blobClientMock = Mock.OfPartial<BlobClient>(MockBehavior.Strict);
Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, {blobClientMock.Object.GetType().Name}");
dotnet run .\test-compat\tunit-mocks-azure-concrete-repro.cs
Expected result
The build fails in TUnit.Mocks generated files when mocking Azure concrete clients (TableClient, BlobClient), with errors like:
CS0460 (constraints on overrides)
CS0115 (no suitable method to override)
CS0122 (inaccessible members)
Proposed Solution
Idealy it would work like moq does now, that decreases friction when migrating. If this is wholly undesired a decision needs to be made if support + warning is valid or no support at all is better to keep people from implementing this as path of least resistance.
moq example
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Azure.Data.Tables" Version="12.11.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.27.0" />
</ItemGroup>
</Project>
using Azure.Data.Tables;
using Azure.Storage.Blobs;
using Moq;
var tableClientMock = new Mock<TableClient>(MockBehavior.Strict);
var blobClientMock = new Mock<BlobClient>(MockBehavior.Strict);
Console.WriteLine($"Created: {tableClientMock.Object.GetType().Name}, {blobClientMock.Object.GetType().Name}");
Alternatives Considered
No response
Feature Category
Other
How important is this feature to you?
Nice to have - would improve my experience
Additional Context
No response
Contribution
Problem Statement
Findings
When migrating from Moq to Tunit.Mocks I encountered the following issue. Since this isn't supported yet, I made this a feature request and not a bug.
Mocking concrete Azure.Data.Tables.TableClient is not supported in Tunit but is in Moq. This complicates the migration.
For now we use Tunit.Mocks 'where possible'
Reproduction
Expected result
The build fails in TUnit.Mocks generated files when mocking Azure concrete clients (
TableClient,BlobClient), with errors like:CS0460(constraints on overrides)CS0115(no suitable method to override)CS0122(inaccessible members)Proposed Solution
Idealy it would work like moq does now, that decreases friction when migrating. If this is wholly undesired a decision needs to be made if support + warning is valid or no support at all is better to keep people from implementing this as path of least resistance.
moq example
Alternatives Considered
No response
Feature Category
Other
How important is this feature to you?
Nice to have - would improve my experience
Additional Context
No response
Contribution