Browse Source

Fixed issue #403

Fixed issue #419
pull/433/head
Ramón Tomás 7 years ago
parent
commit
e9a89ae553
21 changed files with 166 additions and 34 deletions
  1. +7
    -2
      docker-compose-external.override.yml
  2. +3
    -0
      docker-compose-external.yml
  3. +5
    -0
      src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs
  4. +5
    -0
      src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs
  5. +2
    -1
      test/Services/FunctionalTests/Services/Basket/appsettings.json
  6. +23
    -8
      test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs
  7. +2
    -1
      test/Services/FunctionalTests/Services/Catalog/appsettings.json
  8. +2
    -1
      test/Services/FunctionalTests/Services/Location/appsettings.json
  9. +17
    -3
      test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs
  10. +2
    -1
      test/Services/FunctionalTests/Services/Marketing/appsettings.json
  11. +22
    -4
      test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs
  12. +2
    -1
      test/Services/FunctionalTests/Services/Ordering/settings.json
  13. +2
    -1
      test/Services/IntegrationTests/Services/Basket/appsettings.json
  14. +21
    -1
      test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs
  15. +2
    -1
      test/Services/IntegrationTests/Services/Catalog/appsettings.json
  16. +2
    -1
      test/Services/IntegrationTests/Services/Locations/appsettings.json
  17. +17
    -1
      test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs
  18. +2
    -1
      test/Services/IntegrationTests/Services/Marketing/appsettings.json
  19. +22
    -1
      test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs
  20. +4
    -4
      test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs
  21. +2
    -1
      test/Services/IntegrationTests/Services/Ordering/settings.json

+ 7
- 2
docker-compose-external.override.yml View File

@ -1,9 +1,14 @@
version: '2'
version: '3'
services:
sql.data:
environment:
- MSSQL_SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
- MSSQL_PID=Developer
ports:
- "5433:1433"
- "5433:1433"
nosql.data:
ports:
- "27017:27017"

+ 3
- 0
docker-compose-external.yml View File

@ -13,3 +13,6 @@ services:
image: rabbitmq
ports:
- "5672:5672"
nosql.data:
image: mongo

+ 5
- 0
src/Services/Ordering/Ordering.API/Application/Commands/CancelOrderCommandHandler.cs View File

@ -28,6 +28,11 @@ namespace Ordering.API.Application.Commands
public async Task<bool> Handle(CancelOrderCommand command)
{
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
if(orderToUpdate == null)
{
return false;
}
orderToUpdate.SetCancelledStatus();
return await _orderRepository.UnitOfWork.SaveEntitiesAsync();
}


+ 5
- 0
src/Services/Ordering/Ordering.API/Application/Commands/ShipOrderCommandHandler.cs View File

@ -25,6 +25,11 @@ namespace Ordering.API.Application.Commands
public async Task<bool> Handle(ShipOrderCommand command)
{
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
if(orderToUpdate == null)
{
return false;
}
orderToUpdate.SetShippedStatus();
return await _orderRepository.UnitOfWork.SaveEntitiesAsync();
}


+ 2
- 1
test/Services/FunctionalTests/Services/Basket/appsettings.json View File

@ -10,7 +10,8 @@
"IdentityUrl": "http://localhost:5105",
"ConnectionString": "127.0.0.1",
"isTest": "true",
"EventBusConnection": "localhost"
"EventBusConnection": "localhost",
"SubscriptionClientName": "Basket"
}

+ 23
- 8
test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs View File

@ -1,13 +1,13 @@
using FunctionalTests.Middleware;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.Services.Catalog.API;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.IO;
using System.Text;
namespace FunctionalTests.Services.Catalog
{
@ -18,8 +18,23 @@ namespace FunctionalTests.Services.Catalog
var webHostBuilder = WebHost.CreateDefaultBuilder();
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Catalog");
webHostBuilder.UseStartup<Startup>();
return new TestServer(webHostBuilder);
var testServer = new TestServer(webHostBuilder);
testServer.Host
.MigrateDbContext<CatalogContext>((context, services) =>
{
var env = services.GetService<IHostingEnvironment>();
var settings = services.GetService<IOptions<CatalogSettings>>();
var logger = services.GetService<ILogger<CatalogContextSeed>>();
new CatalogContextSeed()
.SeedAsync(context, env, settings, logger)
.Wait();
})
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
return testServer;
}
public static class Get


+ 2
- 1
test/Services/FunctionalTests/Services/Catalog/appsettings.json View File

@ -4,5 +4,6 @@
"IdentityUrl": "http://localhost:5105",
"isTest": "true",
"EventBusConnection": "localhost",
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/"
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/",
"SubscriptionClientName": "Catalog"
}

+ 2
- 1
test/Services/FunctionalTests/Services/Location/appsettings.json View File

@ -4,5 +4,6 @@
"ExternalCatalogBaseUrl": "http://localhost:5101",
"IdentityUrl": "http://localhost:5105",
"isTest": "true",
"EventBusConnection": "localhost"
"EventBusConnection": "localhost",
"SubscriptionClientName": "Location"
}

+ 17
- 3
test/Services/FunctionalTests/Services/Marketing/MarketingScenariosBase.cs View File

@ -3,7 +3,9 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.IO;
public class MarketingScenariosBase
@ -14,9 +16,21 @@
{
var webHostBuilder = WebHost.CreateDefaultBuilder();
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Marketing");
webHostBuilder.UseStartup<MarketingTestsStartup>();
webHostBuilder.UseStartup<MarketingTestsStartup>();
return new TestServer(webHostBuilder);
var testServer = new TestServer(webHostBuilder);
testServer.Host
.MigrateDbContext<MarketingContext>((context, services) =>
{
var logger = services.GetService<ILogger<MarketingContextSeed>>();
new MarketingContextSeed()
.SeedAsync(context, logger)
.Wait();
});
return testServer;
}
}
}

+ 2
- 1
test/Services/FunctionalTests/Services/Marketing/appsettings.json View File

@ -7,5 +7,6 @@
"EventBusConnection": "localhost",
"AzureServiceBusEnabled": false,
"SubscriptionClientName": "Marketing",
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/"
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/",
"SubscriptionClientName": "Marketing"
}

+ 22
- 4
test/Services/FunctionalTests/Services/Ordering/OrderingScenariosBase.cs View File

@ -1,11 +1,15 @@
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 System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.IO;
using System.Text;
namespace FunctionalTests.Services.Ordering
{
@ -21,8 +25,22 @@ namespace FunctionalTests.Services.Ordering
config.AddJsonFile("settings.json");
});
var testServer = new TestServer(webHostBuilder);
return 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


+ 2
- 1
test/Services/FunctionalTests/Services/Ordering/settings.json View File

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

+ 2
- 1
test/Services/IntegrationTests/Services/Basket/appsettings.json View File

@ -10,7 +10,8 @@
"IdentityUrl": "http://localhost:5105",
"ConnectionString": "127.0.0.1",
"isTest": "true",
"EventBusConnection": "localhost"
"EventBusConnection": "localhost",
"SubscriptionClientName": "Basket"
}

+ 21
- 1
test/Services/IntegrationTests/Services/Catalog/CatalogScenarioBase.cs View File

@ -3,7 +3,12 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
using Microsoft.eShopOnContainers.Services.Catalog.API;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.IO;
public class CatalogScenarioBase
@ -14,7 +19,22 @@
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Catalog");
webHostBuilder.UseStartup<Startup>();
return new TestServer(webHostBuilder);
var testServer = new TestServer(webHostBuilder);
testServer.Host
.MigrateDbContext<CatalogContext>((context, services) =>
{
var env = services.GetService<IHostingEnvironment>();
var settings = services.GetService<IOptions<CatalogSettings>>();
var logger = services.GetService<ILogger<CatalogContextSeed>>();
new CatalogContextSeed()
.SeedAsync(context, env, settings, logger)
.Wait();
})
.MigrateDbContext<IntegrationEventLogContext>((_, __) => { });
return testServer;
}
public static class Get


+ 2
- 1
test/Services/IntegrationTests/Services/Catalog/appsettings.json View File

@ -4,5 +4,6 @@
"IdentityUrl": "http://localhost:5105",
"isTest": "true",
"EventBusConnection": "localhost",
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/"
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/",
"SubscriptionClientName": "Catalog"
}

+ 2
- 1
test/Services/IntegrationTests/Services/Locations/appsettings.json View File

@ -4,5 +4,6 @@
"ExternalCatalogBaseUrl": "http://localhost:5101",
"IdentityUrl": "http://localhost:5105",
"isTest": "true",
"EventBusConnection": "localhost"
"EventBusConnection": "localhost",
"SubscriptionClientName": "Locations"
}

+ 17
- 1
test/Services/IntegrationTests/Services/Marketing/MarketingScenariosBase.cs View File

@ -3,6 +3,9 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.eShopOnContainers.Services.Marketing.API.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
using System.IO;
public class MarketingScenarioBase
@ -15,7 +18,20 @@
webHostBuilder.UseContentRoot(Directory.GetCurrentDirectory() + "\\Services\\Marketing");
webHostBuilder.UseStartup<MarketingTestsStartup>();
return new TestServer(webHostBuilder);
var testServer = new TestServer(webHostBuilder);
testServer.Host
.MigrateDbContext<MarketingContext>((context, services) =>
{
var logger = services.GetService<ILogger<MarketingContextSeed>>();
new MarketingContextSeed()
.SeedAsync(context, logger)
.Wait();
});
return testServer;
}
}
}

+ 2
- 1
test/Services/IntegrationTests/Services/Marketing/appsettings.json View File

@ -5,5 +5,6 @@
"IdentityUrl": "http://localhost:5105",
"isTest": "true",
"EventBusConnection": "localhost",
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/"
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/",
"SubscriptionClientName": "Marketing"
}

+ 22
- 1
test/Services/IntegrationTests/Services/Ordering/OrderingScenarioBase.cs View File

@ -4,8 +4,14 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;
using Microsoft.eShopOnContainers.Services.Ordering.API;
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.IO;
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
public class OrderingScenarioBase
{
@ -19,7 +25,22 @@
config.AddJsonFile("settings.json");
});
return new TestServer(webHostBuilder);
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


+ 4
- 4
test/Services/IntegrationTests/Services/Ordering/OrderingScenarios.cs View File

@ -25,7 +25,7 @@
}
[Fact]
public async Task Cancel_order_no_order_created_response_500_status_code()
public async Task Cancel_order_no_order_created_bad_request_response()
{
using (var server = CreateServer())
{
@ -33,12 +33,12 @@
var response = await server.CreateIdempotentClient()
.PutAsync(Put.CancelOrder, content);
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}
}
[Fact]
public async Task Ship_order_no_order_created_response_500_status_code()
public async Task Ship_order_no_order_created_bad_request_response()
{
using (var server = CreateServer())
{
@ -46,7 +46,7 @@
var response = await server.CreateIdempotentClient()
.PutAsync(Put.ShipOrder, content);
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
}
}


+ 2
- 1
test/Services/IntegrationTests/Services/Ordering/settings.json View File

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

Loading…
Cancel
Save