private async Task <ExecutionInfo> ExecHandlerAsync(string handler, string dataIn, string assertLoggedByInitialize) { // The actionWriter using (var actionWriter = new StringWriter()) { var testRuntimeApiClient = new TestRuntimeApiClient(_environmentVariables, _headers); var loggerAction = actionWriter.ToLoggingAction(); var assembly = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(UserCodeLoader.LambdaCoreAssemblyName)); UserCodeLoader.SetCustomerLoggerLogAction(assembly, loggerAction, _internalLogger); var userCodeLoader = new UserCodeLoader(handler, _internalLogger); var handlerWrapper = HandlerWrapper.GetHandlerWrapper(userCodeLoader.Invoke); var initializer = new UserCodeInitializer(userCodeLoader, _internalLogger); var bootstrap = new LambdaBootstrap(handlerWrapper, initializer.InitializeAsync) { Client = testRuntimeApiClient }; if (assertLoggedByInitialize != null) { Assert.False(actionWriter.ToString().Contains($"^^[{assertLoggedByInitialize}]^^")); } await bootstrap.InitializeAsync(); if (assertLoggedByInitialize != null) { Assert.True(actionWriter.ToString().Contains($"^^[{assertLoggedByInitialize}]^^")); } var dataOut = await InvokeAsync(bootstrap, dataIn, testRuntimeApiClient); var actionText = actionWriter.ToString(); return(new ExecutionInfo(bootstrap, dataIn, dataOut, actionText, null, userCodeLoader)); } }