コード例 #1
0
        // private readonly TestRuntimeApiClient _testRuntimeApiClient;

        public HandlerTests(ITestOutputHelper output)
        {
            // setup logger to write to optionally console
            _internalLogger = InternalLogger.GetCustomInternalLogger(output.WriteLine);
            _output         = output;

            var testDateTimeHelper   = new TestDateTimeHelper();
            var cognitoClientContext = File.ReadAllText("CognitoClientContext.json");
            var cognitoIdentity      = File.ReadAllText("CognitoIdentity.json");

            _headers = new Dictionary <string, IEnumerable <string> >
            {
                { RuntimeApiHeaders.HeaderAwsRequestId, new List <string> {
                      "Request1"
                  } },
                { RuntimeApiHeaders.HeaderInvokedFunctionArn, new List <string> {
                      "Arn1"
                  } },
                { RuntimeApiHeaders.HeaderClientContext, new List <string> {
                      cognitoClientContext
                  } },
                { RuntimeApiHeaders.HeaderCognitoIdentity, new List <string> {
                      cognitoIdentity
                  } },
                { RuntimeApiHeaders.HeaderDeadlineMs, new List <string> {
                      $"{(testDateTimeHelper.UtcNow - LambdaContext.UnixEpoch + TimeSpan.FromSeconds(42)).TotalMilliseconds}"
                  } }                                                                                                                                                                // (2020, 1, 1) + 42 seconds
            };

            var env = new Dictionary <string, string>
            {
                { LambdaEnvironment.EnvVarFunctionName, "Name1" },
                { LambdaEnvironment.EnvVarFunctionVersion, "Version1" },
                { LambdaEnvironment.EnvVarLogGroupName, "Group1" },
                { LambdaEnvironment.EnvVarLogStreamName, "Stream1" },
                { LambdaEnvironment.EnvVarFunctionMemorySize, "42" },
            };

            _environmentVariables = new TestEnvironmentVariables(env);
        }