Browse Source

migrate functional tests of ordering api

features/migration-dotnet3
ericuss 5 years ago
parent
commit
6e69b36a77
7 changed files with 30 additions and 16 deletions
  1. +3
    -0
      src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs
  2. +1
    -0
      src/Services/Ordering/Ordering.API/Ordering.API.csproj
  3. +11
    -12
      src/Services/Ordering/Ordering.API/Startup.cs
  4. +1
    -2
      src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj
  5. +11
    -1
      src/Services/Ordering/Ordering.FunctionalTests/OrderingTestStartup.cs
  6. +2
    -1
      src/Services/Ordering/Ordering.FunctionalTests/appsettings.json
  7. +1
    -0
      src/_build/dependencies.props

+ 3
- 0
src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommand.cs View File

@ -12,7 +12,10 @@ namespace Ordering.API.Application.Commands
[DataMember]
public int OrderNumber { get; private set; }
public CancelOrderCommand()
{
}
public CancelOrderCommand(int orderNumber)
{
OrderNumber = orderNumber;


+ 1
- 0
src/Services/Ordering/Ordering.API/Ordering.API.csproj View File

@ -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)" />


+ 11
- 12
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -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 =>
{


+ 1
- 2
src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj View File

@ -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)" />


+ 11
- 1
src/Services/Ordering/Ordering.FunctionalTests/OrderingTestStartup.cs View File

@ -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())


+ 2
- 1
src/Services/Ordering/Ordering.FunctionalTests/appsettings.json View File

@ -6,5 +6,6 @@
"EventBusConnection": "localhost",
"CheckUpdateTime": "30000",
"GracePeriodTime": "1",
"SubscriptionClientName": "Ordering"
"SubscriptionClientName": "Ordering",
"SuppressCheckForUnhandledSecurityMetadata":true
}

+ 1
- 0
src/_build/dependencies.props View File

@ -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…
Cancel
Save