mirror of
https://github.com/bitwarden/server.git
synced 2026-02-13 04:13:42 +08:00
Remove moq (#3166)
This commit is contained in:
@@ -10,7 +10,7 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Vault.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
|
||||
namespace Bit.Infrastructure.EFIntegration.Test.AutoFixture;
|
||||
|
||||
@@ -25,20 +25,16 @@ internal class ServiceScopeFactoryBuilder : ISpecimenBuilder
|
||||
public object Create(object request, ISpecimenContext context)
|
||||
{
|
||||
var fixture = new Fixture();
|
||||
var serviceProvider = new Mock<IServiceProvider>();
|
||||
var serviceProvider = Substitute.For<IServiceProvider>();
|
||||
var dbContext = new DatabaseContext(_options);
|
||||
serviceProvider
|
||||
.Setup(x => x.GetService(typeof(DatabaseContext)))
|
||||
.Returns(dbContext);
|
||||
serviceProvider.GetService(typeof(DatabaseContext)).Returns(dbContext);
|
||||
|
||||
var serviceScope = new Mock<IServiceScope>();
|
||||
serviceScope.Setup(x => x.ServiceProvider).Returns(serviceProvider.Object);
|
||||
var serviceScope = Substitute.For<IServiceScope>();
|
||||
serviceScope.ServiceProvider.Returns(serviceProvider);
|
||||
|
||||
var serviceScopeFactory = new Mock<IServiceScopeFactory>();
|
||||
serviceScopeFactory
|
||||
.Setup(x => x.CreateScope())
|
||||
.Returns(serviceScope.Object);
|
||||
return serviceScopeFactory.Object;
|
||||
var serviceScopeFactory = Substitute.For<IServiceScopeFactory>();
|
||||
serviceScopeFactory.CreateScope().Returns(serviceScope);
|
||||
return serviceScopeFactory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using NSubstitute;
|
||||
|
||||
namespace Bit.Infrastructure.EFIntegration.Test.Helpers;
|
||||
|
||||
@@ -18,17 +18,17 @@ public static class DatabaseOptionsFactory
|
||||
var services = new ServiceCollection()
|
||||
.AddSingleton(sp =>
|
||||
{
|
||||
var dataProtector = new Mock<IDataProtector>();
|
||||
dataProtector
|
||||
.Setup(d => d.Unprotect(It.IsAny<byte[]>()))
|
||||
.Returns<byte[]>(data => Encoding.UTF8.GetBytes(Constants.DatabaseFieldProtectedPrefix + Encoding.UTF8.GetString(data)));
|
||||
var dataProtector = Substitute.For<IDataProtector>();
|
||||
dataProtector.Unprotect(Arg.Any<byte[]>())
|
||||
.Returns<byte[]>(data =>
|
||||
Encoding.UTF8.GetBytes(Constants.DatabaseFieldProtectedPrefix +
|
||||
Encoding.UTF8.GetString((byte[])data[0])));
|
||||
|
||||
var dataProtectionProvider = new Mock<IDataProtectionProvider>();
|
||||
dataProtectionProvider
|
||||
.Setup(x => x.CreateProtector(Constants.DatabaseFieldProtectorPurpose))
|
||||
.Returns(dataProtector.Object);
|
||||
var dataProtectionProvider = Substitute.For<IDataProtectionProvider>();
|
||||
dataProtectionProvider.CreateProtector(Constants.DatabaseFieldProtectorPurpose)
|
||||
.Returns(dataProtector);
|
||||
|
||||
return dataProtectionProvider.Object;
|
||||
return dataProtectionProvider;
|
||||
})
|
||||
.BuildServiceProvider();
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
|
||||
<PackageReference Include="Moq" Version="4.17.2" />
|
||||
<PackageReference Include="NSubstitute" Version="$(NSubstituteVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitRunnerVisualStudioVersion)">
|
||||
|
||||
@@ -38,16 +38,6 @@
|
||||
"Microsoft.TestPlatform.TestHost": "17.1.0"
|
||||
}
|
||||
},
|
||||
"Moq": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.17.2, )",
|
||||
"resolved": "4.17.2",
|
||||
"contentHash": "HytUPJ3/uks2UgJ9hIcyXm3YxpFAR4OJzbQwTHltbKGun3lFLhEHs97hiiPj1dY8jV/kasXeihTzDxct6Zf3iQ==",
|
||||
"dependencies": {
|
||||
"Castle.Core": "4.4.1",
|
||||
"System.Threading.Tasks.Extensions": "4.5.4"
|
||||
}
|
||||
},
|
||||
"NSubstitute": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.3.0, )",
|
||||
@@ -2843,89 +2833,88 @@
|
||||
"common": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Core": "2023.7.2",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"NSubstitute": "4.3.0",
|
||||
"xunit": "2.4.1"
|
||||
"AutoFixture.AutoNSubstitute": "[4.17.0, )",
|
||||
"AutoFixture.Xunit2": "[4.17.0, )",
|
||||
"Core": "[2023.7.2, )",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "[1.2.0, )",
|
||||
"Microsoft.NET.Test.Sdk": "[17.1.0, )",
|
||||
"NSubstitute": "[4.3.0, )",
|
||||
"xunit": "[2.4.1, )"
|
||||
}
|
||||
},
|
||||
"core": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AWSSDK.SQS": "3.7.2.47",
|
||||
"AWSSDK.SimpleEmail": "3.7.0.150",
|
||||
"AspNetCoreRateLimit": "4.0.2",
|
||||
"AspNetCoreRateLimit.Redis": "1.0.1",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "1.3.2",
|
||||
"Azure.Messaging.ServiceBus": "7.15.0",
|
||||
"Azure.Storage.Blobs": "12.14.1",
|
||||
"Azure.Storage.Queues": "12.12.0",
|
||||
"BitPay.Light": "1.0.1907",
|
||||
"Braintree": "5.12.0",
|
||||
"DnsClient": "1.7.0",
|
||||
"Fido2.AspNet": "3.0.1",
|
||||
"Handlebars.Net": "2.1.2",
|
||||
"IdentityServer4": "4.1.2",
|
||||
"IdentityServer4.AccessTokenValidation": "3.0.1",
|
||||
"LaunchDarkly.ServerSdk": "7.0.0",
|
||||
"MailKit": "3.2.0",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "6.0.4",
|
||||
"Microsoft.Azure.Cosmos.Table": "1.0.8",
|
||||
"Microsoft.Azure.NotificationHubs": "4.1.0",
|
||||
"Microsoft.Data.SqlClient": "5.0.1",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "6.0.6",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "6.0.1",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "6.0.1",
|
||||
"Microsoft.Extensions.Identity.Stores": "6.0.4",
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"Otp.NET": "1.2.2",
|
||||
"Quartz": "3.4.0",
|
||||
"SendGrid": "9.27.0",
|
||||
"Sentry.Serilog": "3.16.0",
|
||||
"Serilog.AspNetCore": "5.0.0",
|
||||
"Serilog.Extensions.Logging": "3.1.0",
|
||||
"Serilog.Extensions.Logging.File": "2.0.0",
|
||||
"Serilog.Sinks.AzureCosmosDB": "2.0.0",
|
||||
"Serilog.Sinks.SyslogMessages": "2.0.6",
|
||||
"Stripe.net": "40.0.0",
|
||||
"YubicoDotNetClient": "1.2.0"
|
||||
"AWSSDK.SQS": "[3.7.2.47, )",
|
||||
"AWSSDK.SimpleEmail": "[3.7.0.150, )",
|
||||
"AspNetCoreRateLimit": "[4.0.2, )",
|
||||
"AspNetCoreRateLimit.Redis": "[1.0.1, )",
|
||||
"Azure.Extensions.AspNetCore.DataProtection.Blobs": "[1.3.2, )",
|
||||
"Azure.Messaging.ServiceBus": "[7.15.0, )",
|
||||
"Azure.Storage.Blobs": "[12.14.1, )",
|
||||
"Azure.Storage.Queues": "[12.12.0, )",
|
||||
"BitPay.Light": "[1.0.1907, )",
|
||||
"Braintree": "[5.12.0, )",
|
||||
"DnsClient": "[1.7.0, )",
|
||||
"Fido2.AspNet": "[3.0.1, )",
|
||||
"Handlebars.Net": "[2.1.2, )",
|
||||
"IdentityServer4": "[4.1.2, )",
|
||||
"IdentityServer4.AccessTokenValidation": "[3.0.1, )",
|
||||
"LaunchDarkly.ServerSdk": "[7.0.0, )",
|
||||
"MailKit": "[3.2.0, )",
|
||||
"Microsoft.AspNetCore.Authentication.JwtBearer": "[6.0.4, )",
|
||||
"Microsoft.Azure.Cosmos.Table": "[1.0.8, )",
|
||||
"Microsoft.Azure.NotificationHubs": "[4.1.0, )",
|
||||
"Microsoft.Data.SqlClient": "[5.0.1, )",
|
||||
"Microsoft.Extensions.Caching.StackExchangeRedis": "[6.0.6, )",
|
||||
"Microsoft.Extensions.Configuration.EnvironmentVariables": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Configuration.UserSecrets": "[6.0.1, )",
|
||||
"Microsoft.Extensions.Identity.Stores": "[6.0.4, )",
|
||||
"Newtonsoft.Json": "[13.0.1, )",
|
||||
"Otp.NET": "[1.2.2, )",
|
||||
"Quartz": "[3.4.0, )",
|
||||
"SendGrid": "[9.27.0, )",
|
||||
"Sentry.Serilog": "[3.16.0, )",
|
||||
"Serilog.AspNetCore": "[5.0.0, )",
|
||||
"Serilog.Extensions.Logging": "[3.1.0, )",
|
||||
"Serilog.Extensions.Logging.File": "[2.0.0, )",
|
||||
"Serilog.Sinks.AzureCosmosDB": "[2.0.0, )",
|
||||
"Serilog.Sinks.SyslogMessages": "[2.0.6, )",
|
||||
"Stripe.net": "[40.0.0, )",
|
||||
"YubicoDotNetClient": "[1.2.0, )"
|
||||
}
|
||||
},
|
||||
"core.test": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoFixture.AutoNSubstitute": "4.17.0",
|
||||
"AutoFixture.Xunit2": "4.17.0",
|
||||
"Common": "2023.7.2",
|
||||
"Core": "2023.7.2",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "1.2.0",
|
||||
"Microsoft.NET.Test.Sdk": "17.1.0",
|
||||
"Moq": "4.17.2",
|
||||
"NSubstitute": "4.3.0",
|
||||
"xunit": "2.4.1"
|
||||
"AutoFixture.AutoNSubstitute": "[4.17.0, )",
|
||||
"AutoFixture.Xunit2": "[4.17.0, )",
|
||||
"Common": "[2023.7.2, )",
|
||||
"Core": "[2023.7.2, )",
|
||||
"Kralizek.AutoFixture.Extensions.MockHttp": "[1.2.0, )",
|
||||
"Microsoft.NET.Test.Sdk": "[17.1.0, )",
|
||||
"NSubstitute": "[4.3.0, )",
|
||||
"xunit": "[2.4.1, )"
|
||||
}
|
||||
},
|
||||
"infrastructure.dapper": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"Core": "2023.7.2",
|
||||
"Dapper": "2.0.123"
|
||||
"Core": "[2023.7.2, )",
|
||||
"Dapper": "[2.0.123, )"
|
||||
}
|
||||
},
|
||||
"infrastructure.entityframework": {
|
||||
"type": "Project",
|
||||
"dependencies": {
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "12.0.1",
|
||||
"Core": "2023.7.2",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "7.0.5",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "7.0.5",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "7.0.5",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "7.0.4",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "7.0.0",
|
||||
"linq2db.EntityFrameworkCore": "7.5.0"
|
||||
"AutoMapper.Extensions.Microsoft.DependencyInjection": "[12.0.1, )",
|
||||
"Core": "[2023.7.2, )",
|
||||
"Microsoft.EntityFrameworkCore.Relational": "[7.0.5, )",
|
||||
"Microsoft.EntityFrameworkCore.SqlServer": "[7.0.5, )",
|
||||
"Microsoft.EntityFrameworkCore.Sqlite": "[7.0.5, )",
|
||||
"Npgsql.EntityFrameworkCore.PostgreSQL": "[7.0.4, )",
|
||||
"Pomelo.EntityFrameworkCore.MySql": "[7.0.0, )",
|
||||
"linq2db.EntityFrameworkCore": "[7.5.0, )"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user