private (Mock <ILogger <CoreLogger> > LoggerStub, CorrelationProvider Correlation, CausationProvider Causation) GetHelpers() { var loggerStub = new Mock <ILogger <CoreLogger> >(); var httpContext = new DefaultHttpContext(); var httpRequest = new DefaultHttpRequest(httpContext); var httpContextAccessor = new HttpContextAccessor { HttpContext = httpContext }; var correlation = CorrelationProvider.Create(); var causation = new CausationProvider(httpContextAccessor); httpRequest.Headers.Add("X-Correlation-ID", correlation.CorrelationId.ToString()); return(loggerStub, correlation, causation); }
public static IServiceCollection AddCorrelationAndCausation(this IServiceCollection services) { return(services .AddScoped(s => CorrelationProvider.Create()) .AddScoped <CausationProvider>()); }