Skip to content

Commit 78a3749

Browse files
GeekMashermichaelnebel
authored andcommitted
feat: Add Amazon Lambda testing stubs
1 parent 16e8613 commit 78a3749

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace Amazon.Lambda.APIGatewayEvents
7+
{
8+
public class APIGatewayHttpApiV2ProxyRequest
9+
{
10+
public string RawPath { get; set; }
11+
12+
public string RawQueryString { get; set; }
13+
14+
public string[] Cookies { get; set; }
15+
16+
public IDictionary<string, string> Headers { get; set; }
17+
18+
public IDictionary<string, string> QueryStringParameters { get; set; }
19+
20+
public ProxyRequestContext RequestContext { get; set; }
21+
22+
public string Body { get; set; }
23+
24+
public IDictionary<string, string> PathParameters { get; set; }
25+
26+
public bool IsBase64Encoded { get; set; }
27+
28+
public IDictionary<string, string> StageVariables { get; set; }
29+
30+
public class ProxyRequestContext
31+
{
32+
public string AccountId { get; set; }
33+
34+
public string ApiId { get; set; }
35+
}
36+
}
37+
38+
public class APIGatewayProxyResponse
39+
{
40+
public int StatusCode { get; set; }
41+
42+
public IDictionary<string, string> Headers { get; set; }
43+
44+
public string Body { get; set; }
45+
}
46+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
using System.Collections.Generic;
3+
4+
namespace Amazon.Lambda.Core
5+
{
6+
public interface ILambdaContext
7+
{
8+
string AwsRequestId { get; }
9+
10+
IClientContext ClientContext { get; }
11+
12+
string FunctionName { get; }
13+
14+
string FunctionVersion { get; }
15+
16+
string InvokedFunctionArn { get; }
17+
18+
ILambdaLogger Logger { get; }
19+
20+
string LogGroupName { get; }
21+
22+
string LogStreamName { get; }
23+
24+
int MemoryLimitInMB { get; }
25+
}
26+
27+
public interface IClientContext
28+
{
29+
IDictionary<string, string> Environment { get; }
30+
31+
IClientApplication Client { get; }
32+
33+
IDictionary<string, string> Custom { get; }
34+
}
35+
36+
public interface IClientApplication
37+
{
38+
string AppPackageName { get; }
39+
40+
string AppTitle { get; }
41+
42+
string AppVersionCode { get; }
43+
44+
string AppVersionName { get; }
45+
46+
string InstallationId { get; }
47+
}
48+
49+
public enum LogLevel
50+
{
51+
Trace = 0,
52+
Debug = 1,
53+
Information = 2,
54+
Warning = 3,
55+
Error = 4,
56+
Critical = 5
57+
}
58+
59+
public interface ILambdaLogger
60+
{
61+
void Log(string message);
62+
63+
void LogLine(string message);
64+
65+
void Log(string level, string message) => throw null;
66+
67+
void Log(LogLevel level, string message) => throw null;
68+
69+
void LogTrace(string message) => throw null;
70+
71+
void LogDebug(string message) => throw null;
72+
73+
void LogInformation(string message) => throw null;
74+
75+
void LogWarning(string message) => throw null;
76+
77+
void LogError(string message) => throw null;
78+
79+
void LogCritical(string message) => throw null;
80+
}
81+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net7.0</TargetFramework>
4+
<ImplicitUsings>enable</ImplicitUsings>
5+
<Nullable>enable</Nullable>
6+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
7+
<AWSProjectType>Lambda</AWSProjectType>
8+
<!-- Makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
9+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
10+
<!-- Generate ready to run images during publishing to improve cold start time. -->
11+
<PublishReadyToRun>true</PublishReadyToRun>
12+
</PropertyGroup>
13+
</Project>

0 commit comments

Comments
 (0)