public void Run_ReportsInvocationSuccess() { // arrange A.CallTo(() => _runtime.KeepInvokeLoopRunning()).ReturnsNextFromSequence(true, false); var invokeData = new InvokeData { RequestId = Guid.NewGuid().ToString() }; A.CallTo(() => _runtime.GetNextInvocation()).Returns(invokeData); var environment = A.Fake <IEnvironment>(); A.CallTo(() => _runtime.Environment).Returns(environment); var outputStream = new MemoryStream(); A.CallTo(() => _runner.Handle(A <Stream> .Ignored, A <ILambdaContext> .Ignored)) .Returns(outputStream); // act _bootstrap.Run(); // assert A.CallTo(() => _runtime.ReportInvocationSuccess(invokeData.RequestId, outputStream)) .MustHaveHappened(); }
public void Run() { this.LogDebug("Entering run loop"); while (_runtime.KeepInvokeLoopRunning()) { var requestId = string.Empty; try { var invokeData = _runtime.GetNextInvocation(); requestId = invokeData.RequestId; _runtime.Environment.SetEnvironmentVariable("_X_AMZN_TRACE_ID", invokeData.XAmznTraceId); var outputStream = _runner.Handle(invokeData.InputStream, invokeData.LambdaContext); _runtime.ReportInvocationSuccess(requestId, outputStream); } catch (Exception ex) { _runtime.ReportInvocationError(requestId, ex); } } }