2018-06-27 15:57:37 +02:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
using Microsoft.AspNetCore.TestHost;
|
2018-06-27 15:57:37 +02:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
using System.IO;
|
2018-06-27 15:57:37 +02:00
|
|
|
|
using System.Reflection;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
|
|
|
|
|
namespace Basket.FunctionalTests.Base
|
|
|
|
|
{
|
|
|
|
|
public class BasketScenarioBase
|
|
|
|
|
{
|
|
|
|
|
private const string ApiUrlBase = "api/v1/basket";
|
|
|
|
|
|
|
|
|
|
public TestServer CreateServer()
|
|
|
|
|
{
|
2018-06-27 15:57:37 +02:00
|
|
|
|
var path = Assembly.GetAssembly(typeof(BasketScenarioBase))
|
|
|
|
|
.Location;
|
2018-06-25 11:36:42 +02:00
|
|
|
|
|
2018-06-27 15:57:37 +02:00
|
|
|
|
var hostBuilder = new WebHostBuilder()
|
|
|
|
|
.UseContentRoot(Path.GetDirectoryName(path))
|
|
|
|
|
.ConfigureAppConfiguration(cb =>
|
|
|
|
|
{
|
|
|
|
|
cb.AddJsonFile("appsettings.json", optional: false)
|
|
|
|
|
.AddEnvironmentVariables();
|
|
|
|
|
}).UseStartup<BasketTestsStartup>();
|
|
|
|
|
|
|
|
|
|
return new TestServer(hostBuilder);
|
2018-06-25 11:36:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Get
|
|
|
|
|
{
|
|
|
|
|
public static string GetBasket(int id)
|
|
|
|
|
{
|
|
|
|
|
return $"{ApiUrlBase}/{id}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Post
|
|
|
|
|
{
|
|
|
|
|
public static string Basket = $"{ApiUrlBase}/";
|
|
|
|
|
public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|