Remove Program
This commit is contained in:
		
							parent
							
								
									c59e66861f
								
							
						
					
					
						commit
						d96e4db08c
					
				@ -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>
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -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());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -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,33 +27,36 @@ public class BasketScenarioBase : WebApplicationFactory<Program>
 | 
				
			|||||||
        public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
 | 
					        public static string CheckoutOrder = $"{ApiUrlBase}/checkout";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected override IHost CreateHost(IHostBuilder builder)
 | 
					    private class BasketApplicaton : WebApplicationFactory<Program>
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        builder.ConfigureServices(services =>
 | 
					        protected override IHost CreateHost(IHostBuilder builder)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            services.AddSingleton<IStartupFilter, AuthStartupFilter>();
 | 
					            builder.ConfigureServices(services =>
 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        builder.ConfigureAppConfiguration(c =>
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            var directory = Path.GetDirectoryName(typeof(BasketScenarioBase).Assembly.Location)!;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            c.AddJsonFile(Path.Combine(directory, "appsettings.json"), optional: false);
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return base.CreateHost(builder);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private class AuthStartupFilter : IStartupFilter
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return app =>
 | 
					 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                app.UseMiddleware<AutoAuthorizeMiddleware>();
 | 
					                services.AddSingleton<IStartupFilter, AuthStartupFilter>();
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                next(app);
 | 
					            builder.ConfigureAppConfiguration(c =>
 | 
				
			||||||
            };
 | 
					            {
 | 
				
			||||||
 | 
					                var directory = Path.GetDirectoryName(typeof(BasketScenarioBase).Assembly.Location)!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                c.AddJsonFile(Path.Combine(directory, "appsettings.json"), optional: false);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return base.CreateHost(builder);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private class AuthStartupFilter : IStartupFilter
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return app =>
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    app.UseMiddleware<AutoAuthorizeMiddleware>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    next(app);
 | 
				
			||||||
 | 
					                };
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user