public async Task HandlerThrowsException() { using (var bootstrap = new LambdaBootstrap(_testFunction.BaseHandlerThrowsAsync, null)) { bootstrap.Client = _testRuntimeApiClient; Assert.Null(_environmentVariables.GetEnvironmentVariable(LambdaEnvironment.EnvVarTraceId)); await bootstrap.InvokeOnceAsync(); } Assert.True(_testRuntimeApiClient.ReportInvocationErrorAsyncExceptionCalled); Assert.False(_testInitializer.InitializerWasCalled); Assert.True(_testFunction.HandlerWasCalled); }
public async Task HandlerReturnsNull() { using (var bootstrap = new LambdaBootstrap(_testFunction.BaseHandlerReturnsNullAsync, null)) { _testRuntimeApiClient.FunctionInput = new byte[0]; bootstrap.Client = _testRuntimeApiClient; Assert.Null(_environmentVariables.GetEnvironmentVariable(LambdaEnvironment.EnvVarTraceId)); await bootstrap.InvokeOnceAsync(); } _testRuntimeApiClient.VerifyOutput((byte[])null); Assert.False(_testInitializer.InitializerWasCalled); Assert.True(_testFunction.HandlerWasCalled); }
public async Task TraceIdEnvironmentVariableIsSet() { using (var bootstrap = new LambdaBootstrap(_testFunction.BaseHandlerAsync, null)) { bootstrap.Client = _testRuntimeApiClient; Assert.Null(_environmentVariables.GetEnvironmentVariable(LambdaEnvironment.EnvVarTraceId)); await bootstrap.InvokeOnceAsync(); Assert.NotNull(_testRuntimeApiClient.LastTraceId); Assert.Equal(_testRuntimeApiClient.LastTraceId, _environmentVariables.GetEnvironmentVariable(LambdaEnvironment.EnvVarTraceId)); } Assert.False(_testInitializer.InitializerWasCalled); Assert.True(_testFunction.HandlerWasCalled); }
public async Task HandlerInputAndOutputWork() { const string testInput = "a MiXeD cAsE sTrInG"; using (var bootstrap = new LambdaBootstrap(_testFunction.BaseHandlerToUpperAsync, null)) { _testRuntimeApiClient.FunctionInput = Encoding.UTF8.GetBytes(testInput); bootstrap.Client = _testRuntimeApiClient; Assert.Null(_environmentVariables.GetEnvironmentVariable(LambdaEnvironment.EnvVarTraceId)); await bootstrap.InvokeOnceAsync(); } _testRuntimeApiClient.VerifyOutput(testInput.ToUpper()); Assert.False(_testInitializer.InitializerWasCalled); Assert.True(_testFunction.HandlerWasCalled); }