예제 #1
0
        public void Run_ReportsInvocationError()
        {
            // 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);

            A.CallTo(() => _runner.Handle(A <Stream> .Ignored, A <ILambdaContext> .Ignored))
            .Throws <DivideByZeroException>();

            // act
            _bootstrap.Run();

            // assert
            A.CallTo(() => _runtime.ReportInvocationError(invokeData.RequestId, A <DivideByZeroException> .Ignored))
            .MustHaveHappened();
        }
예제 #2
0
        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);
                }
            }
        }