src/Services/Catalog/Catalog.FunctionalTests/CatalogScenarioBase.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
namespace Catalog.FunctionalTests;
public class CatalogScenariosBase
{
public TestServer CreateServer()
{
var path = Assembly.GetAssembly(typeof(CatalogScenariosBase))
.Location;
var hostBuilder = new WebHostBuilder()
.UseContentRoot(Path.GetDirectoryName(path))
.ConfigureAppConfiguration(cb =>
{
cb.AddJsonFile("appsettings.json", optional: false)
.AddEnvironmentVariables();
})
.UseStartup<Startup>();
var testServer = new TestServer(hostBuilder);
testServer.Host
.MigrateDbContext<CatalogContext>((context, services) =>
{
var env = services.GetService<IWebHostEnvironment>();
var settings = services.GetService<IOptions<CatalogSettings>>();
var logger = services.GetService<ILogger<CatalogContextSeed>>();
new CatalogContextSeed()
.SeedAsync(context, env, settings, logger)
.Wait();
})
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
return testServer;
}
public static class Get
{
private const int PageIndex = 0;
private const int PageCount = 4;
public static string Items(bool paginated = false)
{
return paginated
? "api/v1/catalog/items" + Paginated(PageIndex, PageCount)
: "api/v1/catalog/items";
}
public static string ItemById(int id)
{
return $"api/v1/catalog/items/{id}";
}
public static string ItemByName(string name, bool paginated = false)
{
return paginated
? $"api/v1/catalog/items/withname/{name}" + Paginated(PageIndex, PageCount)
: $"api/v1/catalog/items/withname/{name}";
}
后面还有 18 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。