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]
|
||||
public int OrderNumber { get; private set; }
|
||||
public CancelOrderCommand()
|
||||
{
|
||||
|
||||
}
|
||||
public CancelOrderCommand(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
|
@ -30,6 +30,7 @@
|
||||
</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.Rabbitmq" Version="$(AspNetCore_HealthChecks_Rabbitmq)" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="$(AspNetCore_HealthChecks_SqlServer)" />
|
||||
|
@ -22,6 +22,7 @@
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||
using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
@ -44,7 +45,7 @@
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
public virtual IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddApplicationInsights(Configuration)
|
||||
.AddCustomMvc()
|
||||
@ -81,9 +82,9 @@
|
||||
|
||||
app.UseCors("CorsPolicy");
|
||||
|
||||
app.UseRouting();
|
||||
ConfigureAuth(app);
|
||||
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
@ -149,16 +150,14 @@
|
||||
{
|
||||
// Add framework services.
|
||||
services.AddControllers(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
});
|
||||
//services.AddMvc(options =>
|
||||
// {
|
||||
// options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
// })
|
||||
// .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
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
})
|
||||
// Added for functional tests
|
||||
.AddApplicationPart(typeof(OrdersController).Assembly)
|
||||
.AddNewtonsoftJson()
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
|
||||
;
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
|
@ -17,8 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(Microsoft_AspNetCore_Mvc_Testing)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(Microsoft_NET_Test_Sdk)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(Microsoft_AspNetCore_TestHost)" />
|
||||
<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.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
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)
|
||||
{
|
||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||
|
@ -6,5 +6,6 @@
|
||||
"EventBusConnection": "localhost",
|
||||
"CheckUpdateTime": "30000",
|
||||
"GracePeriodTime": "1",
|
||||
"SubscriptionClientName": "Ordering"
|
||||
"SubscriptionClientName": "Ordering",
|
||||
"SuppressCheckForUnhandledSecurityMetadata":true
|
||||
}
|
||||
|
@ -86,6 +86,7 @@
|
||||
<MongoDB_Driver_Core>2.9.0-beta2</MongoDB_Driver_Core>
|
||||
<Moq>4.10.1</Moq>
|
||||
<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>
|
||||
<Polly>6.0.1</Polly>
|
||||
<IdentityServer4_AspNetIdentity>3.0.0-preview3.4</IdentityServer4_AspNetIdentity>
|
||||
|
Loading…
x
Reference in New Issue
Block a user