Remove Program

This commit is contained in:
David Fowler 2023-05-04 07:48:07 -07:00 committed by Reuben Bond
parent c59e66861f
commit d96e4db08c
7 changed files with 43 additions and 39 deletions

View File

@ -18,4 +18,8 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Services.Common\Services.Common.csproj" /> <ProjectReference Include="..\..\Services.Common\Services.Common.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Basket.FunctionalTests" />
</ItemGroup>
</Project> </Project>

View File

@ -71,7 +71,7 @@ public class BasketController : ControllerBase
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId} from {AppName}", eventMessage.Id, Program.AppName); _logger.LogError(ex, "ERROR Publishing integration event: {IntegrationEventId}", eventMessage.Id);
throw; throw;
} }

View File

@ -15,9 +15,9 @@ public class OrderStartedIntegrationEventHandler : IIntegrationEventHandler<Orde
public async Task Handle(OrderStartedIntegrationEvent @event) public async Task Handle(OrderStartedIntegrationEvent @event)
{ {
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}"))
{ {
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); _logger.LogInformation("----- Handling integration event: {IntegrationEventId} - ({@IntegrationEvent})", @event.Id, @event);
await _repository.DeleteBasketAsync(@event.UserId.ToString()); await _repository.DeleteBasketAsync(@event.UserId.ToString());
} }

View File

@ -15,9 +15,9 @@ public class ProductPriceChangedIntegrationEventHandler : IIntegrationEventHandl
public async Task Handle(ProductPriceChangedIntegrationEvent @event) public async Task Handle(ProductPriceChangedIntegrationEvent @event)
{ {
using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}-{Program.AppName}")) using (LogContext.PushProperty("IntegrationEventContext", $"{@event.Id}"))
{ {
_logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, Program.AppName, @event); _logger.LogInformation("----- Handling integration event: {IntegrationEventId} at {AppName} - ({@IntegrationEvent})", @event.Id, @event);
var userIds = _repository.GetUsers(); var userIds = _repository.GetUsers();

View File

@ -63,12 +63,6 @@ try
} }
catch (Exception ex) catch (Exception ex)
{ {
app.Logger.LogCritical(ex, "Program terminated unexpectedly ({ApplicationContext})!", AppName); app.Logger.LogCritical(ex, "Program terminated unexpectedly");
return 1; return 1;
} }
public partial class Program
{
private static string Namespace = typeof(Program).Assembly.GetName().Name;
public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
}

View File

@ -3,13 +3,14 @@ using Microsoft.Extensions.Hosting;
namespace Basket.FunctionalTests.Base; namespace Basket.FunctionalTests.Base;
public class BasketScenarioBase : WebApplicationFactory<Program> public class BasketScenarioBase
{ {
private const string ApiUrlBase = "api/v1/basket"; private const string ApiUrlBase = "api/v1/basket";
public TestServer CreateServer() public TestServer CreateServer()
{ {
return Server; var factory = new BasketApplicaton();
return factory.Server;
} }
public static class Get public static class Get
@ -26,6 +27,8 @@ public class BasketScenarioBase : WebApplicationFactory<Program>
public static string CheckoutOrder = $"{ApiUrlBase}/checkout"; public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
} }
private class BasketApplicaton : WebApplicationFactory<Program>
{
protected override IHost CreateHost(IHostBuilder builder) protected override IHost CreateHost(IHostBuilder builder)
{ {
builder.ConfigureServices(services => builder.ConfigureServices(services =>
@ -56,3 +59,4 @@ public class BasketScenarioBase : WebApplicationFactory<Program>
} }
} }
} }
}

View File

@ -9,7 +9,8 @@ namespace Basket.FunctionalTests
[Fact] [Fact]
public async Task UpdateBasket_return_and_add_basket() public async Task UpdateBasket_return_and_add_basket()
{ {
var redis = Services.GetRequiredService<ConnectionMultiplexer>(); var server = CreateServer();
var redis = server.Services.GetRequiredService<ConnectionMultiplexer>();
var redisBasketRepository = BuildBasketRepository(redis); var redisBasketRepository = BuildBasketRepository(redis);
@ -26,7 +27,8 @@ namespace Basket.FunctionalTests
[Fact] [Fact]
public async Task Delete_Basket_return_null() public async Task Delete_Basket_return_null()
{ {
var redis = Services.GetRequiredService<ConnectionMultiplexer>(); var server = CreateServer();
var redis = server.Services.GetRequiredService<ConnectionMultiplexer>();
var redisBasketRepository = BuildBasketRepository(redis); var redisBasketRepository = BuildBasketRepository(redis);