migrate functional tests of ordering api
This commit is contained in:
parent
445c43221b
commit
6e69b36a77
@ -12,7 +12,10 @@ namespace Ordering.API.Application.Commands
|
|||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public int OrderNumber { get; private set; }
|
public int OrderNumber { get; private set; }
|
||||||
|
public CancelOrderCommand()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
public CancelOrderCommand(int orderNumber)
|
public CancelOrderCommand(int orderNumber)
|
||||||
{
|
{
|
||||||
OrderNumber = orderNumber;
|
OrderNumber = orderNumber;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(Microsoft_AspNetCore_Mvc_NewtonsoftJson)"/>
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="$(AspNetCore_HealthChecks_AzureServiceBus)" />
|
<PackageReference Include="AspNetCore.HealthChecks.AzureServiceBus" Version="$(AspNetCore_HealthChecks_AzureServiceBus)" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="$(AspNetCore_HealthChecks_Rabbitmq)" />
|
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" Version="$(AspNetCore_HealthChecks_Rabbitmq)" />
|
||||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
|
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||||
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||||
@ -44,7 +45,7 @@
|
|||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddApplicationInsights(Configuration)
|
services.AddApplicationInsights(Configuration)
|
||||||
.AddCustomMvc()
|
.AddCustomMvc()
|
||||||
@ -81,9 +82,9 @@
|
|||||||
|
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
ConfigureAuth(app);
|
ConfigureAuth(app);
|
||||||
|
|
||||||
app.UseRouting();
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapDefaultControllerRoute();
|
endpoints.MapDefaultControllerRoute();
|
||||||
@ -149,16 +150,14 @@
|
|||||||
{
|
{
|
||||||
// Add framework services.
|
// Add framework services.
|
||||||
services.AddControllers(options =>
|
services.AddControllers(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||||
});
|
})
|
||||||
//services.AddMvc(options =>
|
// Added for functional tests
|
||||||
// {
|
.AddApplicationPart(typeof(OrdersController).Assembly)
|
||||||
// options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
.AddNewtonsoftJson()
|
||||||
// })
|
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
|
||||||
// .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
|
;
|
||||||
// .AddControllersAsServices(); //Injecting Controllers themselves thru DI
|
|
||||||
// //For further info see: http://docs.autofac.org/en/latest/integration/aspnetcore.html#controllers-as-services
|
|
||||||
|
|
||||||
services.AddCors(options =>
|
services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(Microsoft_AspNetCore_Mvc_Testing)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(Microsoft_NET_Test_Sdk)" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(Microsoft_NET_Test_Sdk)" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(Microsoft_AspNetCore_TestHost)" />
|
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(Microsoft_AspNetCore_TestHost)" />
|
||||||
<PackageReference Include="xunit" Version="$(xunit)" />
|
<PackageReference Include="xunit" Version="$(xunit)" />
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.API;
|
using Microsoft.eShopOnContainers.Services.Ordering.API;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Ordering.FunctionalTests
|
namespace Ordering.FunctionalTests
|
||||||
{
|
{
|
||||||
@ -10,6 +13,13 @@ namespace Ordering.FunctionalTests
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IServiceProvider ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Added to avoid the Authorize data annotation in test environment.
|
||||||
|
// Property "SuppressCheckForUnhandledSecurityMetadata" in appsettings.json
|
||||||
|
services.Configure<RouteOptions>(Configuration);
|
||||||
|
return base.ConfigureServices(services);
|
||||||
|
}
|
||||||
protected override void ConfigureAuth(IApplicationBuilder app)
|
protected override void ConfigureAuth(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
"EventBusConnection": "localhost",
|
"EventBusConnection": "localhost",
|
||||||
"CheckUpdateTime": "30000",
|
"CheckUpdateTime": "30000",
|
||||||
"GracePeriodTime": "1",
|
"GracePeriodTime": "1",
|
||||||
"SubscriptionClientName": "Ordering"
|
"SubscriptionClientName": "Ordering",
|
||||||
|
"SuppressCheckForUnhandledSecurityMetadata":true
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
<MongoDB_Driver_Core>2.9.0-beta2</MongoDB_Driver_Core>
|
<MongoDB_Driver_Core>2.9.0-beta2</MongoDB_Driver_Core>
|
||||||
<Moq>4.10.1</Moq>
|
<Moq>4.10.1</Moq>
|
||||||
<Newtonsoft_Json>12.0.2</Newtonsoft_Json>
|
<Newtonsoft_Json>12.0.2</Newtonsoft_Json>
|
||||||
|
<Microsoft_AspNetCore_Mvc_NewtonsoftJson>3.0.0-preview7.19365.7</Microsoft_AspNetCore_Mvc_NewtonsoftJson>
|
||||||
<Ocelot>12.0.1</Ocelot>
|
<Ocelot>12.0.1</Ocelot>
|
||||||
<Polly>6.0.1</Polly>
|
<Polly>6.0.1</Polly>
|
||||||
<IdentityServer4_AspNetIdentity>3.0.0-preview3.4</IdentityServer4_AspNetIdentity>
|
<IdentityServer4_AspNetIdentity>3.0.0-preview3.4</IdentityServer4_AspNetIdentity>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user