using Microsoft.AspNetCore;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.TestHost;
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
|
using Microsoft.eShopOnContainers.Services.Ordering.API;
|
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure;
|
|
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using System.IO;
|
|
|
|
namespace Ordering.FunctionalTests.Base
|
|
{
|
|
public class OrderingScenariosBase
|
|
{
|
|
public TestServer CreateServer()
|
|
{
|
|
var webHostBuilder = WebHost.CreateDefaultBuilder();
|
|
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Ordering");
|
|
webHostBuilder.UseStartup<OrderingTestsStartup>();
|
|
webHostBuilder.ConfigureAppConfiguration((builderContext, config) =>
|
|
{
|
|
config.AddJsonFile("settings.json");
|
|
});
|
|
|
|
var testServer = new TestServer(webHostBuilder);
|
|
|
|
testServer.Host
|
|
.MigrateDbContext<OrderingContext>((context, services) =>
|
|
{
|
|
var env = services.GetService<IHostingEnvironment>();
|
|
var settings = services.GetService<IOptions<OrderingSettings>>();
|
|
var logger = services.GetService<ILogger<OrderingContextSeed>>();
|
|
|
|
new OrderingContextSeed()
|
|
.SeedAsync(context, env, settings, logger)
|
|
.Wait();
|
|
})
|
|
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
|
|
|
|
return testServer;
|
|
}
|
|
|
|
public static class Get
|
|
{
|
|
public static string Orders = "api/v1/orders";
|
|
|
|
public static string OrderBy(int id)
|
|
{
|
|
return $"api/v1/orders/{id}";
|
|
}
|
|
}
|
|
|
|
public static class Post
|
|
{
|
|
public static string AddNewOrder = "api/v1/orders/new";
|
|
}
|
|
|
|
public static class Put
|
|
{
|
|
public static string CancelOrder = "api/v1/orders/cancel";
|
|
public static string ShipOrder = "api/v1/orders/ship";
|
|
}
|
|
|
|
public static class Delete
|
|
{
|
|
public static string OrderBy(int id)
|
|
{
|
|
return $"api/v1/orders/{id}";
|
|
}
|
|
}
|
|
}
|
|
}
|