- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在构建 Web 服务并尝试实现一些集成测试,但在运行测试时我看到以下错误;
UseLazyLoadingProxies requires AddEntityFrameworkProxies to be called on the internal service provider used.
谷歌没有为这个错误提供任何有用的结果,我不知道如何解决它。我已尝试将 services.AddEntityFrameworkProxies()
添加到我的 Startup.cs
文件和我的测试项目中的 CustomWebApplicationFactory.cs
文件。都没有解决问题。
这是 IntegrationTests 项目中我的 CustomWebApplicationaFactory.cs
文件;
public class CustomWebApplicationFactory<TStartup> : WebApplicationFactory<Startup>
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
builder.ConfigureServices(services =>
{
// Create a new service provider.
var serviceProvider = new ServiceCollection()
.AddEntityFrameworkInMemoryDatabase()
.BuildServiceProvider();
// Add a database context (AppDbContext) using an in-memory database for testing.
services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseLazyLoadingProxies();
options.UseInMemoryDatabase("InMemoryAppDb");
options.UseInternalServiceProvider(serviceProvider);
});
// Add a database context (AppDbContext) using an in-memory database for testing.
services.AddDbContext<MultiTenantDbContext>(options =>
{
options.UseLazyLoadingProxies();
options.UseInMemoryDatabase("MultiTenantInMemoryAppDb");
options.UseInternalServiceProvider(serviceProvider);
});
// Build the service provider.
var sp = services.BuildServiceProvider();
// Create a scope to obtain a reference to the database contexts
using (var scope = sp.CreateScope())
{
var scopedServices = scope.ServiceProvider;
var appDb = scopedServices.GetRequiredService<ApplicationDbContext>();
var logger = scopedServices.GetRequiredService<ILogger<CustomWebApplicationFactory<TStartup>>>();
// Ensure the database is created.
appDb.Database.EnsureCreated();
try
{
// Seed the database with some specific test data.
SeedData.PopulateTestData(appDb);
}
catch (Exception ex)
{
logger.LogError(ex, "An error occurred seeding the " +
"database with test messages. Error: {ex.Message}");
}
}
});
}
}
最佳答案
我按照错误告诉我的方式解决了这个问题。我向服务提供者添加了 AddEntityFrameworkProxies()
;
// Create a new service provider.
var serviceProvider = new ServiceCollection()
.AddEntityFrameworkInMemoryDatabase()
.AddEntityFrameworkProxies()
.BuildServiceProvider();
关于c# - ASP.NET Core 集成测试 UseLazyLoadingProxies 需要在使用的内部服务提供者上调用 AddEntityFrameworkProxies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57302595/
我一直在寻找文件系统的 Java 命名和目录接口(interface) (JNDI) 服务提供商。 据我所知,Oracle 与 JDK 捆绑在一起,仅提供 RMI、DNS、LDAP 和 COS 服务提
我不熟悉单点登录的概念。我们已经有一个管理其用户的 Java Web 应用程序。现在的要求是,身份验证将由客户端的 SSO Idp(使用 SAML)提供,之后请求将被转发到我们的应用程序。由于我以前没
当我访问 laravel 时,它说 Symfony \ Component \ Debug \ Exception \ FatalErrorException 'Krucas\Notification
我(我们)正在创建一个包,作为我们 future CMS 的核心组件,当然,该包需要一些单元测试。当包注册时,它做的第一件事就是像这样设置后台/前端上下文: class FoundationServi
有没有办法在 Laravel 中仅为某些路由/URL 注册服务提供商?我想知道是否可以仅在需要的地方绑定(bind)服务,以及它是否有助于减少启动时的压力。 最佳答案 我不确定是否可以仅在特定路线上注
有没有办法在 Laravel 中仅为某些路由/URL 注册服务提供商?我想知道是否可以仅在需要的地方绑定(bind)服务,以及它是否有助于减少启动时的压力。 最佳答案 我不确定是否可以仅在特定路线上注
我正在开发一个 Laravel 5 应用程序,现在应用程序的代码应该在多个 laravel 5 应用程序中重复使用,这就是为什么我要创建一个 composer 包,然后我想在任何地方安装这个包具有相同
当使用预配置的服务提供者元数据时,在 spring security 中,扩展元数据委托(delegate)是否应该有 2 个 beans 定义?一个用于 IDP 元数据,一个用于 SP 元数据?
我知道如何绑定(bind)单个类: public function register() { $this->app->bind('search', 'Laracasts\Search\Sear
我创建了扩展 XeroServiceProvide 的自定义服务提供程序,基本上,我有多个 Xero 帐户,我想更改两个配置参数值运行时 消费者 key 和 消费者 secret .有没有快速的方法。
我有一个小程序需要调用JAXP,具体是SAXParserFactory .现在,正如您从 Javadoc 中看到的那样,这在内部使用了服务提供者机制,如文档中所述 here : 具体来说,如果它在我的
我试图找出一个涉及 Spring Security 和 SAML 的问题。我们正在尝试使用 Spring Security (spring-security-core-3.1.1.RELEASE.ja
我需要创建一个 RESTful WCF 服务,它需要使用 OAuth 2.0 对调用者进行身份验证。过去一周我一直在学习 OAuth 和它的提供者实现,这些是我发现的资源,它们接近我想要的。 (1)
我的 someModule 模块有一个服务: someModule.provider('someService', function() { this.options = {}; th
在 view composer documentation 之后我为我的基本 View 创建了一个类 ComposerServiceProvider 和一个 ViewComposer。我想为我站点的管
我收到此错误: BindingResolutionException in compiled.php line 1029: Target [App\Models\Contracts\Repositor
我正在考虑使用 Oracle 数据库作为 Web 服务提供程序并通过 PL/SQL 存储过程实现 Web 服务逻辑的选项。我以前曾编写过存储过程代码,但我不确定我应该朝哪个方向发展才能使用最新的解决方
在 AngularJS 2.0 Heroes 教程解释中指出,如果一个子组件在其 @Component Providers 列表中包含一个服务,那么 Angular 将创建该服务特定于该子组件的单独实
我正在构建一个 Web 应用程序,它将使用 DotNetOpenAuth 提供一个 api 和一个授权服务。我找到了 this example关于如何使用已经存在的服务提供者进行授权,但我想要一个关于
我正在努力在 Websphere Liberty 服务器上启用 samlWeb-2.0。我需要使用我的雇主提供的现有身份提供商来实现服务提供商部分进行身份验证。 samlWeb-2.0 功能已安装并启
我是一名优秀的程序员,十分优秀!