From c4143f5458a23e0a71ccf246946ec01a4728c351 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Thu, 25 Jul 2024 19:26:12 +0300 Subject: [PATCH 1/6] Updated apig & testcontainers projects --- dotnet-test-samples/apigw-lambda-ddb/README.md | 4 ++-- .../src/DeleteProduct/DeleteProduct.csproj | 2 +- .../apigw-lambda-ddb/src/DeleteProduct/Function.cs | 10 +++++----- .../apigw-lambda-ddb/src/GetProduct/Function.cs | 10 +++++----- .../src/GetProduct/GetProduct.csproj | 2 +- .../apigw-lambda-ddb/src/GetProducts/Function.cs | 10 +++++----- .../src/GetProducts/GetProducts.csproj | 2 +- .../apigw-lambda-ddb/src/PutProduct/Function.cs | 10 +++++----- .../src/PutProduct/PutProduct.csproj | 2 +- .../DataAccess/IProductsDAO.cs | 2 +- .../ServerlessTestApi.Core.csproj | 2 +- .../DataAccess/DynamoDbProducts.cs | 2 +- .../ServerlessTestApi.Infrastructure.csproj | 2 +- .../ServerlessTestApi.Infrastructure/Startup.cs | 2 +- dotnet-test-samples/apigw-lambda-ddb/template.yaml | 2 +- .../ApiTests.IntegrationTest.csproj | 2 +- .../ApiTests.UnitTest/ApiTests.UnitTest.csproj | 2 +- .../MockDeleteProductFunctionTests.cs | 8 ++++---- .../MockGetProductFunctionTests.cs | 10 +++++----- .../MockGetProductsFunctionTests.cs | 10 +++++----- .../MockPutProductFunctionTests.cs | 14 +++++++------- .../Fixtures/S3NotificationEnvironmentFixture.cs | 4 ++-- .../tests/S3Notifications.E2ETests/FunctionTest.cs | 1 - dotnet-test-samples/test-containers/README.md | 4 ++-- .../test-containers/TestContainers.sln | 7 ------- .../ServerlessTestApi.Core.csproj | 2 +- .../ServerlessTestApi.Infrastructure.csproj | 2 +- .../src/ServerlessTestApi/Function.cs | 13 ++++++------- .../src/ServerlessTestApi/ServerlessTestApi.csproj | 2 +- dotnet-test-samples/test-containers/template.yaml | 2 +- .../ApiTests.IntegrationTestWithEmulation.csproj | 2 +- 31 files changed, 70 insertions(+), 79 deletions(-) diff --git a/dotnet-test-samples/apigw-lambda-ddb/README.md b/dotnet-test-samples/apigw-lambda-ddb/README.md index a32421c6..51a09880 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/README.md +++ b/dotnet-test-samples/apigw-lambda-ddb/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)]() +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![Amazon: Api Gateway](https://img.shields.io/badge/Amazon-API%20Gateway-blueviolet)]() [![Amazon: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-blueviolet)]() @@ -15,7 +15,7 @@ This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. ## Language -.NET 6 +.NET 8 ## Framework The framework used to deploy the infrastructure is SAM diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/DeleteProduct.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/DeleteProduct.csproj index fe9e6c53..7fdbc640 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/DeleteProduct.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/DeleteProduct.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/Function.cs b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/Function.cs index 284b18a8..70a9e5e5 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/Function.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/Function.cs @@ -19,25 +19,25 @@ namespace DeleteProduct; public class Function { - private readonly IProductsDAO _dataAccess; + private readonly IProductsDao _dataAccess; private readonly ILogger _logger; public Function() : this(Startup.ServiceProvider) { } - public Function(IProductsDAO dataAccess, ILogger logger) + public Function(IProductsDao dataAccess, ILogger logger) : this(NewServiceProvider(dataAccess, logger)) { } private Function(IServiceProvider serviceProvider) { - _dataAccess = serviceProvider.GetRequiredService(); + _dataAccess = serviceProvider.GetRequiredService(); _logger = serviceProvider.GetRequiredService>(); } - private static IServiceProvider NewServiceProvider(IProductsDAO dataAccess, ILogger logger) + private static IServiceProvider NewServiceProvider(IProductsDao dataAccess, ILogger logger) { var container = new System.ComponentModel.Design.ServiceContainer(); - container.AddService(typeof(IProductsDAO), dataAccess); + container.AddService(typeof(IProductsDao), dataAccess); container.AddService(typeof(ILogger), logger); return container; diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/Function.cs b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/Function.cs index 716e153e..b2332482 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/Function.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/Function.cs @@ -19,33 +19,33 @@ namespace GetProduct; public class Function { - private readonly IProductsDAO _dataAccess; + private readonly IProductsDao _dataAccess; private readonly IOptions _jsonOptions; private readonly ILogger _logger; public Function() : this(Startup.ServiceProvider) { } public Function( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) : this(NewServiceProvider(dataAccess, logger, jsonOptions)) { } private Function(IServiceProvider serviceProvider) { - _dataAccess = serviceProvider.GetRequiredService(); + _dataAccess = serviceProvider.GetRequiredService(); _jsonOptions = serviceProvider.GetRequiredService>(); _logger = serviceProvider.GetRequiredService>(); } private static IServiceProvider NewServiceProvider( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) { var container = new System.ComponentModel.Design.ServiceContainer(); - container.AddService(typeof(IProductsDAO), dataAccess); + container.AddService(typeof(IProductsDao), dataAccess); container.AddService(typeof(IOptions), jsonOptions); container.AddService(typeof(ILogger), logger); diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/GetProduct.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/GetProduct.csproj index eebbf775..38e948ad 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/GetProduct.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/GetProduct.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/Function.cs b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/Function.cs index 30b49c94..8d0b013d 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/Function.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/Function.cs @@ -19,33 +19,33 @@ namespace GetProducts; public class Function { - private readonly IProductsDAO _dataAccess; + private readonly IProductsDao _dataAccess; private readonly IOptions _jsonOptions; private readonly ILogger _logger; public Function() : this(Startup.ServiceProvider) { } public Function( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) : this(NewServiceProvider(dataAccess, logger, jsonOptions)) { } private Function(IServiceProvider serviceProvider) { - _dataAccess = serviceProvider.GetRequiredService(); + _dataAccess = serviceProvider.GetRequiredService(); _jsonOptions = serviceProvider.GetRequiredService>(); _logger = serviceProvider.GetRequiredService>(); } private static IServiceProvider NewServiceProvider( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) { var container = new System.ComponentModel.Design.ServiceContainer(); - container.AddService(typeof(IProductsDAO), dataAccess); + container.AddService(typeof(IProductsDao), dataAccess); container.AddService(typeof(IOptions), jsonOptions); container.AddService(typeof(ILogger), logger); diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/GetProducts.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/GetProducts.csproj index ab239a48..7ad2457b 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/GetProducts.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/GetProducts.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/Function.cs b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/Function.cs index 7b465d32..a9a8a961 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/Function.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/Function.cs @@ -19,33 +19,33 @@ namespace PutProduct { public class Function { - private readonly IProductsDAO _dataAccess; + private readonly IProductsDao _dataAccess; private readonly IOptions _jsonOptions; private readonly ILogger _logger; public Function() : this(Startup.ServiceProvider) { } public Function( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) : this(NewServiceProvider(dataAccess, logger, jsonOptions)) { } private Function(IServiceProvider serviceProvider) { - _dataAccess = serviceProvider.GetRequiredService(); + _dataAccess = serviceProvider.GetRequiredService(); _jsonOptions = serviceProvider.GetRequiredService>(); _logger = serviceProvider.GetRequiredService>(); } private static IServiceProvider NewServiceProvider( - IProductsDAO dataAccess, + IProductsDao dataAccess, ILogger logger, IOptions jsonOptions) { var container = new System.ComponentModel.Design.ServiceContainer(); - container.AddService(typeof(IProductsDAO), dataAccess); + container.AddService(typeof(IProductsDao), dataAccess); container.AddService(typeof(IOptions), jsonOptions); container.AddService(typeof(ILogger), logger); diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/PutProduct.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/PutProduct.csproj index fe9e6c53..7fdbc640 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/PutProduct.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/PutProduct.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/DataAccess/IProductsDAO.cs b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/DataAccess/IProductsDAO.cs index 4b5b4863..2ba987f3 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/DataAccess/IProductsDAO.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/DataAccess/IProductsDAO.cs @@ -4,7 +4,7 @@ namespace ServerlessTestApi.Core.DataAccess; -public interface IProductsDAO +public interface IProductsDao { Task GetProduct(string id, CancellationToken cancellationToken); diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj index 8fcc6455..044a0a6e 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 ServerlessTestApi.Core diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/DataAccess/DynamoDbProducts.cs b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/DataAccess/DynamoDbProducts.cs index ba98d7c0..0ce9569e 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/DataAccess/DynamoDbProducts.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/DataAccess/DynamoDbProducts.cs @@ -6,7 +6,7 @@ namespace ServerlessTestApi.Infrastructure.DataAccess; -public class DynamoDbProducts : IProductsDAO +public class DynamoDbProducts : IProductsDao { private readonly IAmazonDynamoDB _dynamoDbClient; private readonly IOptions _options; diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj index 7fae50d6..11fcdf28 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 enable enable diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/Startup.cs b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/Startup.cs index 43f062f7..b5a650c4 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/Startup.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/src/ServerlessTestApi.Infrastructure/Startup.cs @@ -39,7 +39,7 @@ public static void AddDefaultServices(IServiceCollection services) services.TryAddTransient, DynamoDbOptionsValidator>(); services.AddLogging(builder => builder.AddSerilog(logger)); services.TryAddSingleton(static sp => new AmazonDynamoDBClient()); - services.TryAddSingleton(); + services.TryAddSingleton(); } private static IServiceProvider InitializeServiceProvider() diff --git a/dotnet-test-samples/apigw-lambda-ddb/template.yaml b/dotnet-test-samples/apigw-lambda-ddb/template.yaml index 7f59c2af..f277f751 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/template.yaml +++ b/dotnet-test-samples/apigw-lambda-ddb/template.yaml @@ -5,7 +5,7 @@ Globals: Function: MemorySize: 1024 Architectures: [arm64] - Runtime: dotnet6 + Runtime: dotnet8 Timeout: 30 Tracing: Active Environment: diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.IntegrationTest/ApiTests.IntegrationTest.csproj b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.IntegrationTest/ApiTests.IntegrationTest.csproj index 32e425e3..09b4fe0a 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.IntegrationTest/ApiTests.IntegrationTest.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.IntegrationTest/ApiTests.IntegrationTest.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable false diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/ApiTests.UnitTest.csproj b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/ApiTests.UnitTest.csproj index eb44e270..c32dc964 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/ApiTests.UnitTest.csproj +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/ApiTests.UnitTest.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable false diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockDeleteProductFunctionTests.cs b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockDeleteProductFunctionTests.cs index ce7965ea..3513d8b1 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockDeleteProductFunctionTests.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockDeleteProductFunctionTests.cs @@ -19,7 +19,7 @@ public async Task DeleteProduct_With_ProductInDb_Should_ReturnSuccess() .WithHttpMethod(HttpMethod.Delete) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetProduct(A._, A._)) .Returns(Task.FromResult(new ProductDTO("123456", "Test Product", 10))); @@ -48,7 +48,7 @@ public async Task TestLambdaHandler_With_NonDeleteRequests_Should_Return405(stri .WithHttpMethod(httpMethod) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); var function = new Function(fakeProductDao, Logger); // act @@ -67,7 +67,7 @@ public async Task DeleteProduct_With_ErrorInDeleteDataAccess_Should_Return500() .WithHttpMethod(HttpMethod.Delete) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.DeleteProduct(A._, A._)) .Throws(); @@ -89,7 +89,7 @@ public async Task DeleteProduct_With_TimeOut_Should_Return503() .WithHttpMethod(HttpMethod.Delete) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.DeleteProduct(A._, A._)) .Throws(); diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductFunctionTests.cs b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductFunctionTests.cs index 55fa2ed9..6e47c1b4 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductFunctionTests.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductFunctionTests.cs @@ -20,7 +20,7 @@ public async Task GetProduct_Should_ReturnSuccess() .Build(); var expected = new ProductDTO("testid", "test product", 10); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetProduct(A._, A._)) .Returns(Task.FromResult(expected)); @@ -50,7 +50,7 @@ public async Task TestLambdaHandler_WithNonGetRequests_Should_Return405(string h .WithHttpMethod(httpMethod) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); var function = new Function(fakeProductDao, Logger, JsonOptions); // act @@ -69,7 +69,7 @@ public async Task GetProduct_With_ErrorInDataAccess_Should_Return500() .WithHttpMethod(HttpMethod.Get) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetProduct(A._, A._)) .Throws(); @@ -92,7 +92,7 @@ public async Task GetProduct_With_TimeOut_Should_Return503() .WithHttpMethod(HttpMethod.Get) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetProduct(A._, A._)) .Throws(); @@ -115,7 +115,7 @@ public async Task GetProduct_With_ProductNotFound_Should_Return404() .WithPathParameter("id", "123456") .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetProduct(A._, A._)) .Returns(Task.FromResult(null)); diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductsFunctionTests.cs b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductsFunctionTests.cs index b4dea74d..35eca251 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductsFunctionTests.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockGetProductsFunctionTests.cs @@ -17,7 +17,7 @@ public async Task GetProducts_Should_ReturnSuccess() var request = new ApiRequestBuilder() .WithHttpMethod(HttpMethod.Get) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetAllProducts(A._)) .Returns(Task.FromResult( @@ -49,7 +49,7 @@ public async Task GetProducts_With_DataAccessReturnsProducts_Should_ReturnInBody { new("testid", "test product", 10), }); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetAllProducts(A._)) .Returns(Task.FromResult(expected)); @@ -78,7 +78,7 @@ public async Task TestLambdaHandler_With_NonGetRequests_Should_Return405(string .WithHttpMethod(httpMethod) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetAllProducts(A._)) .Returns(Task.FromResult(new ProductWrapper(new List()))); @@ -100,7 +100,7 @@ public async Task GetProducts_With_ErrorInDataAccess_Should_Return500() .WithHttpMethod(HttpMethod.Get) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetAllProducts(A._)) .Throws(); @@ -122,7 +122,7 @@ public async Task GetProducts_With_TimeOut_Should_Return503() .WithHttpMethod(HttpMethod.Get) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.GetAllProducts(A._)) .Throws(); diff --git a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockPutProductFunctionTests.cs b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockPutProductFunctionTests.cs index 24401489..6592cefd 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockPutProductFunctionTests.cs +++ b/dotnet-test-samples/apigw-lambda-ddb/tests/ApiTests.UnitTest/MockPutProductFunctionTests.cs @@ -21,7 +21,7 @@ public async Task PutProduct_WithSuccsfulInsert_Should_Return201() .WithPathParameter("id", dto.Id) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.PutProduct(A._, A._)) @@ -53,7 +53,7 @@ public async Task PutProduct_WithSuccsfulUpdate_Should_Return200() .WithPathParameter("id", dto.Id) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.PutProduct(A._, A._)) .Invokes(ctx => product = ctx.Arguments.Get(0)) @@ -79,7 +79,7 @@ public async Task PutProduct_With_EmptyBody_Should_ReturnBadRequest() .WithPathParameter("id", product.Id) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); var function = new Function(fakeProductDao, Logger, JsonOptions); // act @@ -102,7 +102,7 @@ public async Task PutProduct_With_MismatchingIds_Should_ReturnBadRequest() .WithBody(product) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); var function = new Function(fakeProductDao, Logger, JsonOptions); // act @@ -126,7 +126,7 @@ public async Task TestLambdaHandler_With_NonPutRequests_Should_Return405(string .WithHttpMethod(httpMethod) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); var function = new Function(fakeProductDao, Logger, JsonOptions); // act @@ -148,7 +148,7 @@ public async Task PutProduct_With_ErrorInDataAccess_Should_Return500() .WithBody(product) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.PutProduct(A._, A._)) .ThrowsAsync(new NullReferenceException()); @@ -174,7 +174,7 @@ public async Task PutProduct_With_TimeOut_Should_Return503() .WithBody(product) .Build(); - var fakeProductDao = A.Fake(); + var fakeProductDao = A.Fake(); A.CallTo(() => fakeProductDao.PutProduct(A._, A._)) .ThrowsAsync(new TaskCanceledException()); diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/Fixtures/S3NotificationEnvironmentFixture.cs b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/Fixtures/S3NotificationEnvironmentFixture.cs index 46025b19..2154b7dd 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/Fixtures/S3NotificationEnvironmentFixture.cs +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/Fixtures/S3NotificationEnvironmentFixture.cs @@ -19,7 +19,7 @@ public class S3NotificationEnvironmentFixture : IAsyncLifetime, IDisposable public S3NotificationEnvironmentFixture() { - var regionName = Environment.GetEnvironmentVariable("AWS_SAM_REGION_NAME") ?? "us-east-1"; + var regionName = Environment.GetEnvironmentVariable("AWS_SAM_REGION_NAME") ?? "eu-west-2"; _regionEndpoint = RegionEndpoint.GetBySystemName(regionName); @@ -35,7 +35,7 @@ public void Dispose() public async Task InitializeAsync() { - var stackName = Environment.GetEnvironmentVariable("AWS_SAM_STACK_NAME") ?? "async-lambda-sqs"; + var stackName = Environment.GetEnvironmentVariable("AWS_SAM_STACK_NAME") ?? "async-sqs"; using var cloudFormationClient = new AmazonCloudFormationClient( new AmazonCloudFormationConfig { diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/FunctionTest.cs b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/FunctionTest.cs index 86867e73..13dfe4a6 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/FunctionTest.cs +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/FunctionTest.cs @@ -32,7 +32,6 @@ public async Task TestS3EventLambdaFunction() // Create a bucket an object to setup a test data. - await _s3Client.PutBucketAsync(_bucketName); await _s3Client.PutObjectAsync(new PutObjectRequest { BucketName = _bucketName, diff --git a/dotnet-test-samples/test-containers/README.md b/dotnet-test-samples/test-containers/README.md index 2c2a2743..b9b177ec 100644 --- a/dotnet-test-samples/test-containers/README.md +++ b/dotnet-test-samples/test-containers/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)]() +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![Amazon: Api Gateway](https://img.shields.io/badge/Amazon-API%20Gateway-blueviolet)]() [![Amazon: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-blueviolet)]() @@ -15,7 +15,7 @@ This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. ## Language -.NET 6 +.NET 8 ## Framework The framework used to deploy the infrastructure is SAM diff --git a/dotnet-test-samples/test-containers/TestContainers.sln b/dotnet-test-samples/test-containers/TestContainers.sln index dd8e8593..0f630f60 100644 --- a/dotnet-test-samples/test-containers/TestContainers.sln +++ b/dotnet-test-samples/test-containers/TestContainers.sln @@ -14,8 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{34C302B9-937 template.yaml = template.yaml EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests.IntegrationTest", "tests\ApiTests.IntegrationTest\ApiTests.IntegrationTest.csproj", "{98CD0930-4F51-4245-AB46-3781CA0D7054}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests.IntegrationTestWithEmulation", "tests\ApiTests.IntegrationTestWithEmulation\ApiTests.IntegrationTestWithEmulation.csproj", "{2B3CD15C-5E66-41F9-AFC7-B49C48F47718}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessTestApi.Infrastructure", "src\ServerlessTestApi.Infrastructure\ServerlessTestApi.Infrastructure.csproj", "{207932BC-077A-49F3-90B4-DA7C3E48CBA5}" @@ -39,10 +37,6 @@ Global {69BC342F-3C16-41EB-A4EE-8421B6BEF748}.Debug|Any CPU.Build.0 = Debug|Any CPU {69BC342F-3C16-41EB-A4EE-8421B6BEF748}.Release|Any CPU.ActiveCfg = Release|Any CPU {69BC342F-3C16-41EB-A4EE-8421B6BEF748}.Release|Any CPU.Build.0 = Release|Any CPU - {98CD0930-4F51-4245-AB46-3781CA0D7054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98CD0930-4F51-4245-AB46-3781CA0D7054}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98CD0930-4F51-4245-AB46-3781CA0D7054}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98CD0930-4F51-4245-AB46-3781CA0D7054}.Release|Any CPU.Build.0 = Release|Any CPU {2B3CD15C-5E66-41F9-AFC7-B49C48F47718}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2B3CD15C-5E66-41F9-AFC7-B49C48F47718}.Debug|Any CPU.Build.0 = Debug|Any CPU {2B3CD15C-5E66-41F9-AFC7-B49C48F47718}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -58,7 +52,6 @@ Global GlobalSection(NestedProjects) = preSolution {F823F114-972C-4F26-94CB-FA092E8EEC21} = {34C302B9-9379-45E5-B648-22DFC7396F01} {69BC342F-3C16-41EB-A4EE-8421B6BEF748} = {34C302B9-9379-45E5-B648-22DFC7396F01} - {98CD0930-4F51-4245-AB46-3781CA0D7054} = {E02638DF-C5C2-4389-8AF8-97BF2A0666ED} {2B3CD15C-5E66-41F9-AFC7-B49C48F47718} = {E02638DF-C5C2-4389-8AF8-97BF2A0666ED} {207932BC-077A-49F3-90B4-DA7C3E48CBA5} = {34C302B9-9379-45E5-B648-22DFC7396F01} EndGlobalSection diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj b/dotnet-test-samples/test-containers/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj index 8fcc6455..044a0a6e 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi.Core/ServerlessTestApi.Core.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 ServerlessTestApi.Core diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj b/dotnet-test-samples/test-containers/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj index 7fae50d6..11fcdf28 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi.Infrastructure/ServerlessTestApi.Infrastructure.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 enable enable diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi/Function.cs b/dotnet-test-samples/test-containers/src/ServerlessTestApi/Function.cs index abc0d925..14e656ac 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi/Function.cs +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi/Function.cs @@ -16,9 +16,9 @@ namespace ServerlessTestApi; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using ServerlessTestApi.Core.DataAccess; -using ServerlessTestApi.Core.Models; -using ServerlessTestApi.Infrastructure; +using Core.DataAccess; +using Core.Models; +using Infrastructure; public class Function { @@ -31,9 +31,9 @@ public Function( ILogger logger, IOptions jsonOptions) { - this._dataAccess = dataAccess; - this._logger = logger; - this._jsonOptions = jsonOptions; + _dataAccess = dataAccess; + _logger = logger; + _jsonOptions = jsonOptions; } [LambdaFunction] @@ -174,7 +174,6 @@ public async Task DeleteProduct( string id, ILambdaContext context) { - UpsertResult result; using var cts = context.GetCancellationTokenSource(); diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi/ServerlessTestApi.csproj b/dotnet-test-samples/test-containers/src/ServerlessTestApi/ServerlessTestApi.csproj index 4a5a8076..41c47cda 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi/ServerlessTestApi.csproj +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi/ServerlessTestApi.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/test-containers/template.yaml b/dotnet-test-samples/test-containers/template.yaml index fab55790..6fe9fcd3 100644 --- a/dotnet-test-samples/test-containers/template.yaml +++ b/dotnet-test-samples/test-containers/template.yaml @@ -5,7 +5,7 @@ Globals: Function: MemorySize: 1024 Architectures: [arm64] - Runtime: dotnet6 + Runtime: dotnet8 Timeout: 30 Tracing: Active Environment: diff --git a/dotnet-test-samples/test-containers/tests/ApiTests.IntegrationTestWithEmulation/ApiTests.IntegrationTestWithEmulation.csproj b/dotnet-test-samples/test-containers/tests/ApiTests.IntegrationTestWithEmulation/ApiTests.IntegrationTestWithEmulation.csproj index b771cab4..784f6daa 100644 --- a/dotnet-test-samples/test-containers/tests/ApiTests.IntegrationTestWithEmulation/ApiTests.IntegrationTestWithEmulation.csproj +++ b/dotnet-test-samples/test-containers/tests/ApiTests.IntegrationTestWithEmulation/ApiTests.IntegrationTestWithEmulation.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable false From 2e43bae0bbcfb0d84b7e4400a3ca45b0a58118c7 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Wed, 31 Jul 2024 12:43:15 +0300 Subject: [PATCH 2/6] Updated hexagonal Architecture --- .../src/GetStock/Adapters/StockDynamoDb.cs | 2 +- .../src/GetStock/Functions.cs | 2 +- .../src/GetStock/GetStock.csproj | 16 ++++---- .../hexagonal-architecture/template.yaml | 2 +- .../Adapters/StockDynamoDbTests.cs | 7 +--- .../Fixtures/DynamoDbTestBase.cs | 38 +++++++++++++++---- .../GetStock.IntegrationTest.csproj | 14 +++---- .../GetStock.UnitTest.csproj | 14 +++---- 8 files changed, 56 insertions(+), 39 deletions(-) diff --git a/dotnet-test-samples/hexagonal-architecture/src/GetStock/Adapters/StockDynamoDb.cs b/dotnet-test-samples/hexagonal-architecture/src/GetStock/Adapters/StockDynamoDb.cs index c0ac291e..6c874eb7 100644 --- a/dotnet-test-samples/hexagonal-architecture/src/GetStock/Adapters/StockDynamoDb.cs +++ b/dotnet-test-samples/hexagonal-architecture/src/GetStock/Adapters/StockDynamoDb.cs @@ -28,7 +28,7 @@ public async Task GetStockValueAsync(string stockId) } var jsonString = document.ToJson(); - return JsonSerializer.Deserialize(jsonString); + return JsonSerializer.Deserialize(jsonString)!; } } diff --git a/dotnet-test-samples/hexagonal-architecture/src/GetStock/Functions.cs b/dotnet-test-samples/hexagonal-architecture/src/GetStock/Functions.cs index 095ff280..6bf50769 100644 --- a/dotnet-test-samples/hexagonal-architecture/src/GetStock/Functions.cs +++ b/dotnet-test-samples/hexagonal-architecture/src/GetStock/Functions.cs @@ -44,7 +44,7 @@ private static ServiceProvider InitializeServiceProvider() public class Functions { - private readonly IHttpHandler? _handler; + private readonly IHttpHandler _handler; public Functions() { diff --git a/dotnet-test-samples/hexagonal-architecture/src/GetStock/GetStock.csproj b/dotnet-test-samples/hexagonal-architecture/src/GetStock/GetStock.csproj index 17bdbb18..d86811df 100644 --- a/dotnet-test-samples/hexagonal-architecture/src/GetStock/GetStock.csproj +++ b/dotnet-test-samples/hexagonal-architecture/src/GetStock/GetStock.csproj @@ -1,6 +1,6 @@  - net6.0 + net8.0 enable enable true @@ -11,13 +11,13 @@ true - - - - - - - + + + + + + + diff --git a/dotnet-test-samples/hexagonal-architecture/template.yaml b/dotnet-test-samples/hexagonal-architecture/template.yaml index 920c2744..248b38ac 100644 --- a/dotnet-test-samples/hexagonal-architecture/template.yaml +++ b/dotnet-test-samples/hexagonal-architecture/template.yaml @@ -5,7 +5,7 @@ Globals: Function: MemorySize: 1024 Architectures: [arm64] - Runtime: dotnet6 + Runtime: dotnet8 Timeout: 30 Tracing: Active diff --git a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Adapters/StockDynamoDbTests.cs b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Adapters/StockDynamoDbTests.cs index 0678c152..23262d6f 100644 --- a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Adapters/StockDynamoDbTests.cs +++ b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Adapters/StockDynamoDbTests.cs @@ -7,13 +7,8 @@ namespace GetStock.IntegrationTest.Adapters; -public class StockDynamoDbTests : DynamoDbTestBase +public class StockDynamoDbTests(DynamoDbFixture fixture) : DynamoDbTestBase(fixture) { - public StockDynamoDbTests(DynamoDbFixture fixture) - : base("test-stocks", fixture) - { - } - [Fact] public async Task GetStockValue_With_StockNotInDb_Should_ThrowStockNotFoundException() { diff --git a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Fixtures/DynamoDbTestBase.cs b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Fixtures/DynamoDbTestBase.cs index e12b563b..fce49b15 100644 --- a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Fixtures/DynamoDbTestBase.cs +++ b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/Fixtures/DynamoDbTestBase.cs @@ -5,27 +5,49 @@ namespace GetStock.IntegrationTest.Fixtures { public class DynamoDbTestBase : IClassFixture, IDisposable { - private const string _tableNamePrefix = "test-stocks"; + private const string TableNamePrefix = "test-stocks"; protected string TableName { get; } protected IAmazonDynamoDB Client { get; } - public DynamoDbTestBase(string tableNamePrefix, DynamoDbFixture fixture) + protected DynamoDbTestBase(DynamoDbFixture fixture) { - TableName = $"{_tableNamePrefix}{Guid.NewGuid()}"; + TableName = $"{TableNamePrefix}{Guid.NewGuid()}"; Client = fixture.Client; var request = new CreateTableRequest { TableName = TableName, - AttributeDefinitions = new List - { - new("StockId", "S") - }, - KeySchema = new List { new("StockId", Amazon.DynamoDBv2.KeyType.HASH) }, + AttributeDefinitions = [new AttributeDefinition("StockId", "S")], + KeySchema = [new KeySchemaElement("StockId", KeyType.HASH)], ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 1, WriteCapacityUnits = 1 } }; Client.CreateTableAsync(request).Wait(); + + WaitUntilDynamoDbActive().Wait(); + } + + private async Task WaitUntilDynamoDbActive() + { + int sleepDuration = 2000; + + var describeTableRequest = new DescribeTableRequest + { + TableName = TableName + }; + + TableStatus status; + + do + { + Thread.Sleep(sleepDuration); + + var describeTableResponse = await Client.DescribeTableAsync(describeTableRequest); + status = describeTableResponse.Table.TableStatus; + + Console.Write("."); + } + while (status != TableStatus.ACTIVE); } public void Dispose() diff --git a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/GetStock.IntegrationTest.csproj b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/GetStock.IntegrationTest.csproj index dbb95107..78f55e0f 100644 --- a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/GetStock.IntegrationTest.csproj +++ b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.IntegrationTest/GetStock.IntegrationTest.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable @@ -9,18 +9,18 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.UnitTest/GetStock.UnitTest.csproj b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.UnitTest/GetStock.UnitTest.csproj index f4636221..ebfed714 100644 --- a/dotnet-test-samples/hexagonal-architecture/tests/GetStock.UnitTest/GetStock.UnitTest.csproj +++ b/dotnet-test-samples/hexagonal-architecture/tests/GetStock.UnitTest/GetStock.UnitTest.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable @@ -11,15 +11,15 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all From ac28a30d5d1bc16861031fc8a53e91a75ba60fe5 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Wed, 31 Jul 2024 14:31:14 +0300 Subject: [PATCH 3/6] Upgraded projects to dotnet8 --- .../ServerlessTestSamples.Core.csproj | 4 ++-- .../ServerlessTestSamples.Integrations.csproj | 14 ++++++------ .../ServerlessTestSamples.csproj | 16 +++++++------- .../template.yaml | 2 +- ...rverlessTestSamples.IntegrationTest.csproj | 18 +++++++-------- .../ServerlessTestSamples.UnitTest.csproj | 18 +++++++-------- .../AsyncTesting.S3EventHandler.csproj | 16 +++++++------- .../async-lambda-dynamodb/template.yaml | 2 +- .../AsyncTesting.IntegrationTest.csproj | 18 +++++++-------- .../AsyncTesting.IntegrationTest/Setup.cs | 15 ++++++------- .../TextTransformerE2ETest.cs | 18 +++++++-------- ...syncTesting.IntegrationTestListener.csproj | 18 +++++++-------- .../S3Notifications/S3Notifications.csproj | 14 ++++++------ .../async-lambda-sqs/template.yaml | 2 +- .../S3Notifications.E2ETests.csproj | 12 +++++----- .../S3Notifications.TestUtilities.csproj | 8 +++---- .../S3Notifications.UnitTests.csproj | 12 +++++----- .../S3Notifications.integrationTests.csproj | 10 ++++----- .../KinesisEventHandler.Infrastructure.csproj | 22 +++++++++---------- .../KinesisEventHandler.Repositories.csproj | 8 +++---- .../KinesisEventHandler.csproj | 14 ++++++------ .../kinesis-lambda-dynamodb/src/template.yaml | 2 +- ...inesisEventHandler.IntegrationTests.csproj | 16 +++++++------- .../KinesisEventHandler.UnitTests.csproj | 14 ++++++------ .../CreateCustomerFunction.csproj | 14 ++++++------ .../serverless.template | 12 +++++++--- .../SchemaTesting.Shared.csproj | 12 +++++----- .../schema-and-contract-testing/template.yaml | 2 +- .../EventBusEventOverride.cs | 12 +++++----- .../SchemaTesting.SchemaRegistry.csproj | 22 +++++++++---------- .../SchemaTesting.SchemaRegistry/Setup.cs | 6 ++--- .../SchemaTesting.UnitTest/ContractTests.cs | 8 +++---- .../SchemaTesting.UnitTest.csproj | 20 ++++++++--------- .../SQSEventHandler/SQSEventHandler.csproj | 16 +++++++------- .../SqsEventHandler.Infrastructure.csproj | 20 ++++++++--------- .../SqsEventHandler.Repositories.csproj | 8 +++---- .../sqs-lambda/src/template.yaml | 2 +- .../SqsEventHandler.IntegrationTests.csproj | 16 +++++++------- .../SqsEventHandler.UnitTests.csproj | 14 ++++++------ 39 files changed, 241 insertions(+), 236 deletions(-) diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Core/ServerlessTestSamples.Core.csproj b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Core/ServerlessTestSamples.Core.csproj index 300a65da..c5171f3a 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Core/ServerlessTestSamples.Core.csproj +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Core/ServerlessTestSamples.Core.csproj @@ -1,13 +1,13 @@ - net6.0 + net8.0 enable enable - + diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Integrations/ServerlessTestSamples.Integrations.csproj b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Integrations/ServerlessTestSamples.Integrations.csproj index bcfb9e87..013e9d7d 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Integrations/ServerlessTestSamples.Integrations.csproj +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples.Integrations/ServerlessTestSamples.Integrations.csproj @@ -5,16 +5,16 @@ - - - - - - + + + + + + - net6.0 + net8.0 enable enable diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples/ServerlessTestSamples.csproj b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples/ServerlessTestSamples.csproj index 1929b711..95ed2ce4 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples/ServerlessTestSamples.csproj +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/src/ServerlessTestSamples/ServerlessTestSamples.csproj @@ -1,19 +1,19 @@ - net6.0 + net8.0 true Lambda - - - - - - - + + + + + + + diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/template.yaml b/dotnet-test-samples/apigw-lambda-list-s3-buckets/template.yaml index 2290ea4b..819b59f8 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/template.yaml +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/template.yaml @@ -8,7 +8,7 @@ Globals: Function: Tracing: PassThrough Timeout: 10 - Runtime: dotnet6 + Runtime: dotnet8 Architectures: - arm64 Environment: diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.IntegrationTest/ServerlessTestSamples.IntegrationTest.csproj b/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.IntegrationTest/ServerlessTestSamples.IntegrationTest.csproj index 5594e1d4..1899ee93 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.IntegrationTest/ServerlessTestSamples.IntegrationTest.csproj +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.IntegrationTest/ServerlessTestSamples.IntegrationTest.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable enable false @@ -12,17 +12,17 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.UnitTest/ServerlessTestSamples.UnitTest.csproj b/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.UnitTest/ServerlessTestSamples.UnitTest.csproj index 67582ac7..9bdb9505 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.UnitTest/ServerlessTestSamples.UnitTest.csproj +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/tests/ServerlessTestSamples.UnitTest/ServerlessTestSamples.UnitTest.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable false @@ -13,17 +13,17 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/async-lambda-dynamodb/src/AsyncTesting.S3EventHandler/AsyncTesting.S3EventHandler.csproj b/dotnet-test-samples/async-lambda-dynamodb/src/AsyncTesting.S3EventHandler/AsyncTesting.S3EventHandler.csproj index 5865dc3e..ff56c3ca 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/src/AsyncTesting.S3EventHandler/AsyncTesting.S3EventHandler.csproj +++ b/dotnet-test-samples/async-lambda-dynamodb/src/AsyncTesting.S3EventHandler/AsyncTesting.S3EventHandler.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 enable enable true @@ -11,12 +11,12 @@ true - - - - - - - + + + + + + + \ No newline at end of file diff --git a/dotnet-test-samples/async-lambda-dynamodb/template.yaml b/dotnet-test-samples/async-lambda-dynamodb/template.yaml index d4e4a560..cb1b80aa 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/template.yaml +++ b/dotnet-test-samples/async-lambda-dynamodb/template.yaml @@ -25,7 +25,7 @@ Globals: # https://docs.aws.amazon.com/serverless-application-model/latest/devel Function: Timeout: 15 MemorySize: 256 - Runtime: dotnet6 + Runtime: dotnet8 Tracing: Active # https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html Environment: Variables: diff --git a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/AsyncTesting.IntegrationTest.csproj b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/AsyncTesting.IntegrationTest.csproj index 2c9e94cd..dfd1a5e5 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/AsyncTesting.IntegrationTest.csproj +++ b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/AsyncTesting.IntegrationTest.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -9,17 +9,17 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/Setup.cs b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/Setup.cs index be429606..89f2efae 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/Setup.cs +++ b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/Setup.cs @@ -10,18 +10,17 @@ public class Setup : IAsyncLifetime { - private string? _tableName; public IAmazonDynamoDB? DynamoDbClient { get; set; } - public IAmazonS3 S3Client { get; set; } + public IAmazonS3 S3Client { get; set; } = null!; - public string SourceBucketName { get; set; } + public string SourceBucketName { get; set; }= null!; - public string DestinationBucketName { get; set; } + public string DestinationBucketName { get; set; }= null!; - public string DestinationTableName { get; set; } + public string DestinationTableName { get; set; }= null!; - public List CreatedFiles { get; set; } = new(); + public List CreatedFiles { get; } = new(); public async Task InitializeAsync() { @@ -64,8 +63,8 @@ await this.S3Client.DeleteObjectAsync( try { - await this.DynamoDbClient.DeleteItemAsync( - this.DestinationTableName, + await this.DynamoDbClient!.DeleteItemAsync( + DestinationTableName, new Dictionary(1) { { "id", new AttributeValue(file) } diff --git a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/TextTransformerE2ETest.cs b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/TextTransformerE2ETest.cs index 35f593ed..73470810 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/TextTransformerE2ETest.cs +++ b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTest/TextTransformerE2ETest.cs @@ -57,13 +57,13 @@ public async Task PutObjectToS3_With_InvalidFileFormat_Should_NotTriggerAsyncPro // Act var testString = "hello world"; - await this.PutObjectIntoSourceBucket( + await PutObjectIntoSourceBucket( testString, - this.setup.SourceBucketName, + setup.SourceBucketName, testFileName); // Assert - var result = await this.PollForProcessedMessage(testFileName); + var result = await PollForProcessedMessage(testFileName); result.Should().BeNull(); } @@ -86,16 +86,16 @@ await this.setup.S3Client.PutObjectAsync( this.setup.CreatedFiles.Add(testFilename); } - private async Task PollForProcessedMessage(string testFilename) + private async Task PollForProcessedMessage(string testFilename) { var pollAttempts = 0; while (pollAttempts < MAX_POLL_ATTEMPTS) { - this.outputHelper.WriteLine($"Poll attempt {pollAttempts}"); + outputHelper.WriteLine($"Poll attempt {pollAttempts}"); - var result = await this.setup.DynamoDbClient.GetItemAsync( - this.setup.DestinationTableName, + var result = await this.setup.DynamoDbClient!.GetItemAsync( + setup.DestinationTableName, new Dictionary(1) { { "id", new AttributeValue(testFilename) } @@ -103,14 +103,14 @@ private async Task PollForProcessedMessage(string testFilename) if (result.IsItemSet) { - this.outputHelper.WriteLine($"Message found after {pollAttempts} attempt(s), returning"); + outputHelper.WriteLine($"Message found after {pollAttempts} attempt(s), returning"); return result.Item["message"].S; } pollAttempts++; - this.outputHelper.WriteLine($"Wait for {POLL_INTERVAL}"); + outputHelper.WriteLine($"Wait for {POLL_INTERVAL}"); await Task.Delay(TimeSpan.FromSeconds(POLL_INTERVAL)); } diff --git a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTestListener/AsyncTesting.IntegrationTestListener.csproj b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTestListener/AsyncTesting.IntegrationTestListener.csproj index a74b3d54..b40b36f7 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTestListener/AsyncTesting.IntegrationTestListener.csproj +++ b/dotnet-test-samples/async-lambda-dynamodb/tests/AsyncTesting.IntegrationTestListener/AsyncTesting.IntegrationTestListener.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 enable enable true @@ -11,13 +11,13 @@ true - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/dotnet-test-samples/async-lambda-sqs/src/S3Notifications/S3Notifications.csproj b/dotnet-test-samples/async-lambda-sqs/src/S3Notifications/S3Notifications.csproj index 95c69f2f..e274d017 100644 --- a/dotnet-test-samples/async-lambda-sqs/src/S3Notifications/S3Notifications.csproj +++ b/dotnet-test-samples/async-lambda-sqs/src/S3Notifications/S3Notifications.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 enable enable true @@ -14,11 +14,11 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/dotnet-test-samples/async-lambda-sqs/template.yaml b/dotnet-test-samples/async-lambda-sqs/template.yaml index 2ff7ec8d..b91b749a 100644 --- a/dotnet-test-samples/async-lambda-sqs/template.yaml +++ b/dotnet-test-samples/async-lambda-sqs/template.yaml @@ -8,7 +8,7 @@ Globals: Function: MemorySize: 256 Architectures: [arm64] - Runtime: dotnet6 + Runtime: dotnet8 Timeout: 300 Tracing: Active Parameters: diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/S3Notifications.E2ETests.csproj b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/S3Notifications.E2ETests.csproj index 4773f888..935c342c 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/S3Notifications.E2ETests.csproj +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.E2ETests/S3Notifications.E2ETests.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 enable enable @@ -8,12 +8,12 @@ - + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.TestUtilities/S3Notifications.TestUtilities.csproj b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.TestUtilities/S3Notifications.TestUtilities.csproj index c19103bf..74d74bf0 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.TestUtilities/S3Notifications.TestUtilities.csproj +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.TestUtilities/S3Notifications.TestUtilities.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -12,9 +12,9 @@ - - - + + + diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.UnitTests/S3Notifications.UnitTests.csproj b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.UnitTests/S3Notifications.UnitTests.csproj index e0c194b1..d57b0ce8 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.UnitTests/S3Notifications.UnitTests.csproj +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.UnitTests/S3Notifications.UnitTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -10,14 +10,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.integrationTests/S3Notifications.integrationTests.csproj b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.integrationTests/S3Notifications.integrationTests.csproj index cdc92ffd..2291919e 100644 --- a/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.integrationTests/S3Notifications.integrationTests.csproj +++ b/dotnet-test-samples/async-lambda-sqs/tests/S3Notifications.integrationTests/S3Notifications.integrationTests.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -10,13 +10,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Infrastructure/KinesisEventHandler.Infrastructure.csproj b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Infrastructure/KinesisEventHandler.Infrastructure.csproj index 9fc88e50..f535f778 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Infrastructure/KinesisEventHandler.Infrastructure.csproj +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Infrastructure/KinesisEventHandler.Infrastructure.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable KinesisEventHandler.Infrastructure @@ -13,16 +13,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Repositories/KinesisEventHandler.Repositories.csproj b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Repositories/KinesisEventHandler.Repositories.csproj index 694c0fdf..94c851df 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Repositories/KinesisEventHandler.Repositories.csproj +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler.Repositories/KinesisEventHandler.Repositories.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable KinesisEventHandler.Repositories @@ -13,9 +13,9 @@ - - - + + + diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler/KinesisEventHandler.csproj b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler/KinesisEventHandler.csproj index d16210c6..c47dfc22 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler/KinesisEventHandler.csproj +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/src/KinesisEventHandler/KinesisEventHandler.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true Lambda KinesisEventHandler @@ -11,12 +11,12 @@ - - - - - - + + + + + + diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/src/template.yaml b/dotnet-test-samples/kinesis-lambda-dynamodb/src/template.yaml index 24994755..d6689f7c 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/src/template.yaml +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/src/template.yaml @@ -10,7 +10,7 @@ Globals: MemorySize: 1024 Architectures: - arm64 - Runtime: dotnet6 + Runtime: dotnet8 Tracing: Active Environment: Variables: diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.IntegrationTests/KinesisEventHandler.IntegrationTests.csproj b/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.IntegrationTests/KinesisEventHandler.IntegrationTests.csproj index 3667449e..37579c39 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.IntegrationTests/KinesisEventHandler.IntegrationTests.csproj +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.IntegrationTests/KinesisEventHandler.IntegrationTests.csproj @@ -3,21 +3,21 @@ enable enable - net6.0 + net8.0 - - - - + + + + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.UnitTests/KinesisEventHandler.UnitTests.csproj b/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.UnitTests/KinesisEventHandler.UnitTests.csproj index 6806f207..d746efca 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.UnitTests/KinesisEventHandler.UnitTests.csproj +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/tests/KinesisEventHandler.UnitTests/KinesisEventHandler.UnitTests.csproj @@ -1,18 +1,18 @@ - net6.0 + net8.0 - + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/CreateCustomerFunction.csproj b/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/CreateCustomerFunction.csproj index c4f53b12..5b52bd0d 100644 --- a/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/CreateCustomerFunction.csproj +++ b/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/CreateCustomerFunction.csproj @@ -1,18 +1,18 @@  - net6.0 + net8.0 enable enable - - - - - - + + + + + + diff --git a/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/serverless.template b/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/serverless.template index 1e18c411..15a065bf 100644 --- a/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/serverless.template +++ b/dotnet-test-samples/schema-and-contract-testing/src/CreateCustomerFunction/serverless.template @@ -1,7 +1,7 @@ { "AWSTemplateFormatVersion": "2010-09-09", "Transform": "AWS::Serverless-2016-10-31", - "Description": "This template is partially managed by Amazon.Lambda.Annotations (v1.0.0.0).", + "Description": "This template is partially managed by Amazon.Lambda.Annotations (v1.5.0.0).", "Resources": { "CreateCustomerFunctionFunctionFunctionHandlerGenerated": { "Type": "AWS::Serverless::Function", @@ -9,10 +9,16 @@ "Tool": "Amazon.Lambda.Annotations", "SyncedEvents": [ "RootPost" - ] + ], + "SyncedEventProperties": { + "RootPost": [ + "Path", + "Method" + ] + } }, "Properties": { - "Runtime": "dotnet6", + "Runtime": "dotnet8", "CodeUri": ".", "MemorySize": 256, "Timeout": 30, diff --git a/dotnet-test-samples/schema-and-contract-testing/src/SchemaTesting.Shared/SchemaTesting.Shared.csproj b/dotnet-test-samples/schema-and-contract-testing/src/SchemaTesting.Shared/SchemaTesting.Shared.csproj index 7973b9d4..2a9a8b66 100644 --- a/dotnet-test-samples/schema-and-contract-testing/src/SchemaTesting.Shared/SchemaTesting.Shared.csproj +++ b/dotnet-test-samples/schema-and-contract-testing/src/SchemaTesting.Shared/SchemaTesting.Shared.csproj @@ -1,17 +1,17 @@ - net6.0 + net8.0 enable enable - - - - - + + + + + diff --git a/dotnet-test-samples/schema-and-contract-testing/template.yaml b/dotnet-test-samples/schema-and-contract-testing/template.yaml index 5c84f638..d3fcf1da 100644 --- a/dotnet-test-samples/schema-and-contract-testing/template.yaml +++ b/dotnet-test-samples/schema-and-contract-testing/template.yaml @@ -12,7 +12,7 @@ Globals: MemorySize: 1024 Architectures: - x86_64 - Runtime: dotnet6 + Runtime: dotnet8 Timeout: 30 Tracing: Active Environment: diff --git a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/EventBusEventOverride.cs b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/EventBusEventOverride.cs index ad142f1d..f5c11a8f 100644 --- a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/EventBusEventOverride.cs +++ b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/EventBusEventOverride.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; -using SchemaTesting.Shared; +using Shared; /// /// Schemas stored in EventBridge Schema Registry include the wrapper. @@ -15,13 +15,13 @@ public class EventBusEventOverride : PutEventsRequestEntry where T : Event { public EventBusEventOverride(object eventObject) { - var evt = (eventObject as T); + var evt = (T)eventObject; - this.Detail = new EventWrapper(evt); + Detail = new EventWrapper(evt); - this.Id = Guid.NewGuid().ToString(); + Id = Guid.NewGuid().ToString(); DetailType = evt.Type; - Resources = Array.Empty(); + Resources = []; Source = "com.customer"; EventBusName = "custom-event-bus"; Time = DateTime.Now; @@ -40,7 +40,7 @@ public EventBusEventOverride(object eventObject) public new object[] Resources { get; set; } [JsonProperty("id")] - public new string Id { get; set; } + public string Id { get; set; } [JsonProperty("source")] public new string Source { get; set; } diff --git a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/SchemaTesting.SchemaRegistry.csproj b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/SchemaTesting.SchemaRegistry.csproj index d8260314..81b43b5f 100644 --- a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/SchemaTesting.SchemaRegistry.csproj +++ b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/SchemaTesting.SchemaRegistry.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -10,19 +10,19 @@ - - - - - - - - - + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/Setup.cs b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/Setup.cs index c6fd2350..d3f772c1 100644 --- a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/Setup.cs +++ b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.SchemaRegistry/Setup.cs @@ -6,8 +6,8 @@ public class Setup : IAsyncLifetime { - public ISchemaReader SchemaReader { get; private set; } - + public ISchemaReader SchemaReader { get; private set; } = null!; + public async Task InitializeAsync() { var stackName = Environment.GetEnvironmentVariable("AWS_SAM_STACK_NAME") ?? "schema-testing"; @@ -17,7 +17,7 @@ public async Task InitializeAsync() var response = await cloudFormationClient.DescribeStacksAsync(new DescribeStacksRequest() { StackName = stackName }); var outputs = response.Stacks[0].Outputs; - this.SchemaReader = new EventBridgeSchemaRegistryReader(); + SchemaReader = new EventBridgeSchemaRegistryReader(); } public Task DisposeAsync() diff --git a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/ContractTests.cs b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/ContractTests.cs index 2d9d7796..1167267f 100644 --- a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/ContractTests.cs +++ b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/ContractTests.cs @@ -20,15 +20,15 @@ public ContractTests() { this._publishedEvents = new List(); this._mockEventPublisher = A.Fake(); - A.CallTo(() => this._mockEventPublisher.Publish(A._)) + A.CallTo(() => _mockEventPublisher.Publish(A._)) .Invokes( - (fakedCall) => + fakedCall => { var evt = fakedCall.Arguments.Get("evt"); - this._publishedEvents.Add(evt.Payload as BaseCustomerCreatedEvent); + _publishedEvents.Add(evt!.Payload as BaseCustomerCreatedEvent); }); - this._schemaReader = new LocalDiskSchemaReader(); + _schemaReader = new LocalDiskSchemaReader(); } [Fact] diff --git a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/SchemaTesting.UnitTest.csproj b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/SchemaTesting.UnitTest.csproj index 6b055ee8..2d152802 100644 --- a/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/SchemaTesting.UnitTest.csproj +++ b/dotnet-test-samples/schema-and-contract-testing/tests/SchemaTesting.UnitTest/SchemaTesting.UnitTest.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 enable enable @@ -11,18 +11,18 @@ - - - - - - - - + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/sqs-lambda/src/SQSEventHandler/SQSEventHandler.csproj b/dotnet-test-samples/sqs-lambda/src/SQSEventHandler/SQSEventHandler.csproj index 6741c7ff..886ac010 100644 --- a/dotnet-test-samples/sqs-lambda/src/SQSEventHandler/SQSEventHandler.csproj +++ b/dotnet-test-samples/sqs-lambda/src/SQSEventHandler/SQSEventHandler.csproj @@ -1,19 +1,19 @@ - net6.0 + net8.0 true Lambda - - - - - - - + + + + + + + diff --git a/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Infrastructure/SqsEventHandler.Infrastructure.csproj b/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Infrastructure/SqsEventHandler.Infrastructure.csproj index ba3e2b9b..23146376 100644 --- a/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Infrastructure/SqsEventHandler.Infrastructure.csproj +++ b/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Infrastructure/SqsEventHandler.Infrastructure.csproj @@ -1,21 +1,21 @@ - net6.0 + net8.0 enable enable - - - - - - - - - + + + + + + + + + diff --git a/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Repositories/SqsEventHandler.Repositories.csproj b/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Repositories/SqsEventHandler.Repositories.csproj index 4c0d8b50..d3f60b74 100644 --- a/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Repositories/SqsEventHandler.Repositories.csproj +++ b/dotnet-test-samples/sqs-lambda/src/SqsEventHandler.Repositories/SqsEventHandler.Repositories.csproj @@ -1,15 +1,15 @@ - net6.0 + net8.0 enable enable - - - + + + diff --git a/dotnet-test-samples/sqs-lambda/src/template.yaml b/dotnet-test-samples/sqs-lambda/src/template.yaml index 6690a28a..aff65339 100644 --- a/dotnet-test-samples/sqs-lambda/src/template.yaml +++ b/dotnet-test-samples/sqs-lambda/src/template.yaml @@ -10,7 +10,7 @@ Globals: MemorySize: 1024 Architectures: - arm64 - Runtime: dotnet6 + Runtime: dotnet8 Tracing: Active Environment: Variables: diff --git a/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.IntegrationTests/SqsEventHandler.IntegrationTests.csproj b/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.IntegrationTests/SqsEventHandler.IntegrationTests.csproj index e9c2df99..8aa1e6c8 100644 --- a/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.IntegrationTests/SqsEventHandler.IntegrationTests.csproj +++ b/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.IntegrationTests/SqsEventHandler.IntegrationTests.csproj @@ -3,21 +3,21 @@ enable enable - net6.0 + net8.0 - - - - + + + + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.UnitTests/SqsEventHandler.UnitTests.csproj b/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.UnitTests/SqsEventHandler.UnitTests.csproj index b711d973..bceb445a 100644 --- a/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.UnitTests/SqsEventHandler.UnitTests.csproj +++ b/dotnet-test-samples/sqs-lambda/tests/SqsEventHandler.UnitTests/SqsEventHandler.UnitTests.csproj @@ -2,18 +2,18 @@ SqsEventHandler.UnitTests - net6.0 + net8.0 - + - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From 69ba2ad3435cdc5020ebe1eb54a29ca933f85975 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Thu, 1 Aug 2024 12:16:25 +0300 Subject: [PATCH 4/6] Updated documentation and metadata and fixed leftovers from .NET6 --- dotnet-test-samples/README.md | 4 ++-- dotnet-test-samples/apigw-lambda-ddb/README.md | 4 ++-- .../src/DeleteProduct/aws-lambda-tools-defaults.json | 2 +- .../src/GetProduct/aws-lambda-tools-defaults.json | 2 +- .../src/GetProducts/aws-lambda-tools-defaults.json | 2 +- .../src/PutProduct/aws-lambda-tools-defaults.json | 2 +- .../apigw-lambda-list-s3-buckets/README.md | 6 +++--- dotnet-test-samples/async-lambda-dynamodb/README.md | 4 ++-- dotnet-test-samples/async-lambda-sqs/README.md | 4 ++-- dotnet-test-samples/hexagonal-architecture/README.md | 8 ++++---- dotnet-test-samples/kinesis-lambda-dynamodb/README.md | 8 ++++---- dotnet-test-samples/kinesis-lambda-dynamodb/metadata.json | 2 +- dotnet-test-samples/load-testing/README.md | 2 +- dotnet-test-samples/sqs-lambda/README.md | 8 ++++---- dotnet-test-samples/sqs-lambda/metadata.json | 2 +- dotnet-test-samples/test-containers/README.md | 4 ++-- .../src/DeleteProduct/aws-lambda-tools-defaults.json | 2 +- .../test-containers/src/GetProducts/GetProducts.csproj | 2 +- .../src/GetProducts/aws-lambda-tools-defaults.json | 2 +- .../src/PutProduct/aws-lambda-tools-defaults.json | 2 +- .../src/ServerlessTestApi/aws-lambda-tools-defaults.json | 2 +- .../src/ServerlessTestApi/serverless.template | 8 ++++---- 22 files changed, 41 insertions(+), 41 deletions(-) diff --git a/dotnet-test-samples/README.md b/dotnet-test-samples/README.md index f1f32c9a..19c1adee 100644 --- a/dotnet-test-samples/README.md +++ b/dotnet-test-samples/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) # .NET Test Samples @@ -12,7 +12,7 @@ This portion of the repository contains code samples for testing serverless appl |[Hexagonal Architecture](./hexagonal-architecture)|An example of hexagonal architecture implemented using AWS Lambda with tests.| |[Kinesis Data Streams](./kinesis-lambda-dynamodb/)|This project contains unit and integration tests for a pattern using Kinesis Data Streams, AWS Lambda and Amazon DynamoDB.| |[SQS with AWS Lambda and DynamoDb](./sqs-lambda)|This project contains unit and integration tests for AWS Lambda that is invoked by Amazon Simple Queue Service (SQS)| -|[Local testing using containers](./test-containers)|This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 6. It also demonstrates how you can use a local emulated version of DynamoDB to increase the speed of feedback loops as you make changes to your application code.| +|[Local testing using containers](./test-containers)|This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 8. It also demonstrates how you can use a local emulated version of DynamoDB to increase the speed of feedback loops as you make changes to your application code.| |[Load Testing](./load-testing)|A description of how load testing can be carried out before deploying to production | ## Test Asynchronous Architectures diff --git a/dotnet-test-samples/apigw-lambda-ddb/README.md b/dotnet-test-samples/apigw-lambda-ddb/README.md index 51a09880..c5d613f2 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/README.md +++ b/dotnet-test-samples/apigw-lambda-ddb/README.md @@ -10,7 +10,7 @@ ### Description -This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 6. +This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 8. Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. @@ -199,7 +199,7 @@ sam delete * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed -* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed +* [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet) installed ## Video Walkthroughs diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/aws-lambda-tools-defaults.json b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/aws-lambda-tools-defaults.json index e21ca34d..580dc7a9 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/apigw-lambda-ddb/src/DeleteProduct/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "DeleteProduct::DeleteProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/aws-lambda-tools-defaults.json b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/aws-lambda-tools-defaults.json index 67fdd408..02bb3dc5 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProduct/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "GetProduct::GetProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/aws-lambda-tools-defaults.json b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/aws-lambda-tools-defaults.json index 2bc3d241..f2b841fb 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/apigw-lambda-ddb/src/GetProducts/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "GetProducts::GetProducts.Function::FunctionHandler" diff --git a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/aws-lambda-tools-defaults.json b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/aws-lambda-tools-defaults.json index 38672a3f..9fe5013c 100644 --- a/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/apigw-lambda-ddb/src/PutProduct/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "PutProduct::PutProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/apigw-lambda-list-s3-buckets/README.md b/dotnet-test-samples/apigw-lambda-list-s3-buckets/README.md index 39daed9a..6f258d19 100644 --- a/dotnet-test-samples/apigw-lambda-list-s3-buckets/README.md +++ b/dotnet-test-samples/apigw-lambda-list-s3-buckets/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)]() +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![Amazon: Api Gateway](https://img.shields.io/badge/Amazon-API%20Gateway-blueviolet)]() [![Amazon: S3](https://img.shields.io/badge/Amazon-S3-blueviolet)]() @@ -40,7 +40,7 @@ The SAM CLI is an extension of the AWS CLI that adds functionality for building To use the SAM CLI, you need the following tools. * SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -* .NET 6 - [Install .NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) +* .NET 8 - [Install .NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) * Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) [[top]](#dotnet-test-samples) @@ -508,7 +508,7 @@ Globals: Function: # Tracing: PassThrough Timeout: 10 - Runtime: dotnet6 + Runtime: dotnet8 Architectures: - arm64 # Api: diff --git a/dotnet-test-samples/async-lambda-dynamodb/README.md b/dotnet-test-samples/async-lambda-dynamodb/README.md index 01045749..492e5b22 100644 --- a/dotnet-test-samples/async-lambda-dynamodb/README.md +++ b/dotnet-test-samples/async-lambda-dynamodb/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)]() +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![Amazon: S3](https://img.shields.io/badge/Amazon-S3-blueviolet)]() [![Amazon: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-blueviolet)]() @@ -39,7 +39,7 @@ The SAM CLI is an extension of the AWS CLI that adds functionality for building To use the SAM CLI, you need the following tools. - SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -- .NET 6 - [Install .NET 6](https://dotnet.microsoft.com/en-us/download) +- .NET 8 - [Install .NET 8](https://dotnet.microsoft.com/en-us/download) [[top]](#asynchronous-integration-test-with-lambda-event-listener-and-dynamodb) diff --git a/dotnet-test-samples/async-lambda-sqs/README.md b/dotnet-test-samples/async-lambda-sqs/README.md index 2c0424a4..eb7cc35c 100644 --- a/dotnet-test-samples/async-lambda-sqs/README.md +++ b/dotnet-test-samples/async-lambda-sqs/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)]() +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![Amazon: S3](https://img.shields.io/badge/Amazon-S3-blueviolet)]() [![Amazon: SQS](https://img.shields.io/badge/Amazon-SQS-blueviolet)]() @@ -36,7 +36,7 @@ The SAM CLI is an extension of the AWS CLI that adds functionality for building To use the SAM CLI, you need the following tools. - SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) -- .NET 6 - [Install .NET 6](https://dotnet.microsoft.com/en-us/download) +- .NET 8 - [Install .NET 8](https://dotnet.microsoft.com/en-us/download) ## Build the project diff --git a/dotnet-test-samples/hexagonal-architecture/README.md b/dotnet-test-samples/hexagonal-architecture/README.md index 863fa130..9376e0a5 100644 --- a/dotnet-test-samples/hexagonal-architecture/README.md +++ b/dotnet-test-samples/hexagonal-architecture/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)](https://img.shields.io/badge/AWS-Lambda-blueviolet) [![Amazon: API Gateway](https://img.shields.io/badge/Amazon-API%20Gateway-blueviolet)]() [![Amazon: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-blueviolet)]() @@ -23,12 +23,12 @@ In Lambda functions, hexagonal architecture can help you implement new business ### Application description The example application is a backend web service built using Amazon API Gateway, AWS Lambda, and Amazon DynamoDB. Business logic in the domain layer should be tested with unit tests. Responses from secondary actors via ports should be mocked during unit testing to speed up test execution. -This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 6. +This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET. **Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred.** ## Language -.NET 6 +.NET 8 ## Framework The framework used to deploy the infrastructure is SAM @@ -218,5 +218,5 @@ It uses the [IClassFixture](https://xunit.net/docs/shared-context) feature of [x * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed -* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed +* [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet) installed * [Fixer.io - 3rd party service to retrieve real-time currencies value for this example](https://fixer.io/) \ No newline at end of file diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/README.md b/dotnet-test-samples/kinesis-lambda-dynamodb/README.md index fe43c0ae..e9690cfc 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/README.md +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)]() [![AWS: Kinesis](https://img.shields.io/badge/AWS-Kinesis-blueviolet)]() [![AWS: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-blueviolet)]() @@ -9,12 +9,12 @@ ### Description -This pattern creates an AWS Lambda function that consumes messages from an Amazon Kinesis Data Streams and dumps them to Amazon DynamoDB using SAM and .NET 6. +This pattern creates an AWS Lambda function that consumes messages from an Amazon Kinesis Data Streams and dumps them to Amazon DynamoDB using SAM and .NET. > **Important:** *This application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred.* ## Language -.NET 6 +.NET 8 ## Framework The framework used to deploy the infrastructure is [SAM](https://aws.amazon.com/serverless/sam) @@ -272,4 +272,4 @@ sam delete * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed -* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed \ No newline at end of file +* [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet) installed \ No newline at end of file diff --git a/dotnet-test-samples/kinesis-lambda-dynamodb/metadata.json b/dotnet-test-samples/kinesis-lambda-dynamodb/metadata.json index a62cf85d..98b2ac49 100644 --- a/dotnet-test-samples/kinesis-lambda-dynamodb/metadata.json +++ b/dotnet-test-samples/kinesis-lambda-dynamodb/metadata.json @@ -1,6 +1,6 @@ { "title": "Amazon Kinesis Data Streams with AWS Lambda Function & Amazon DynamoDB", - "description": "This pattern creates an AWS Lambda function that consumes messages from an Amazon Kinesis Data Streams and dumps them to Amazon DynamoDB using SAM and .NET 6.", + "description": "This pattern creates an AWS Lambda function that consumes messages from an Amazon Kinesis Data Streams and dumps them to Amazon DynamoDB using SAM and .NET 8.", "content_language": "English", "language": ".NET", "type": ["Unit", "Integration"], diff --git a/dotnet-test-samples/load-testing/README.md b/dotnet-test-samples/load-testing/README.md index 89ffbe6e..9985b73b 100644 --- a/dotnet-test-samples/load-testing/README.md +++ b/dotnet-test-samples/load-testing/README.md @@ -1,4 +1,4 @@ -[![.NET: 6.0](https://img.shields.io/badge/.NET-6.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) +[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)](https://img.shields.io/badge/AWS-Lambda-blueviolet) [![test: unit](https://img.shields.io/badge/Test-Unit-blue)](https://img.shields.io/badge/Test-Unit-blue) [![test: integration](https://img.shields.io/badge/Test-Integration-yellow)](https://img.shields.io/badge/Test-Integration-yellow) diff --git a/dotnet-test-samples/sqs-lambda/README.md b/dotnet-test-samples/sqs-lambda/README.md index 2afd487f..abab52a5 100644 --- a/dotnet-test-samples/sqs-lambda/README.md +++ b/dotnet-test-samples/sqs-lambda/README.md @@ -1,4 +1,4 @@ -[![Built with: .Net 6](https://img.shields.io/badge/Microsoft-.Net%206-blue?style=plastic&logo=microsoft)](https://learn.microsoft.com/en-us/dotnet/core/introduction) +[![Built with: .Net 8](https://img.shields.io/badge/Microsoft-.Net%208-blue?style=plastic&logo=microsoft)](https://learn.microsoft.com/en-us/dotnet/core/introduction) [![Amazon: SQS](https://img.shields.io/badge/Amazon-SQS-blueviolet?style=plastic&logo=amazonaws)]() [![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-orange?style=plastic&logo=amazonaws)]() [![AWS: DynamoDB](https://img.shields.io/badge/Amazon-DynamoDB-darkblue?style=plastic&logo=amazonaws)]() @@ -9,12 +9,12 @@ ### Description -This pattern creates an AWS Lambda function that consumes messages from an Amazon Simple Queue Service (Amazon SQS) queue using SAM and .NET 6. +This pattern creates an AWS Lambda function that consumes messages from an Amazon Simple Queue Service (Amazon SQS) queue using SAM and .NET 8. > **Important:** *This application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred.* ## Language -.NET 6 +.NET 8 ## Framework The framework used to deploy the infrastructure is [SAM](https://aws.amazon.com/serverless/sam) @@ -258,4 +258,4 @@ sam delete * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed -* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed \ No newline at end of file +* [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet) installed \ No newline at end of file diff --git a/dotnet-test-samples/sqs-lambda/metadata.json b/dotnet-test-samples/sqs-lambda/metadata.json index 8ca43d51..8fa0c911 100644 --- a/dotnet-test-samples/sqs-lambda/metadata.json +++ b/dotnet-test-samples/sqs-lambda/metadata.json @@ -1,6 +1,6 @@ { "title": "Amazon Simple Queue Service (SQS), AWS Lambda Function & Amazon DynamoDB", - "description": "This project contains an AWS Lambda function that consumes messages from an Amazon Simple Queue Service (Amazon SQS) and inserts them to Amazon DynamoDB using SAM and .NET 6.", + "description": "This project contains an AWS Lambda function that consumes messages from an Amazon Simple Queue Service (Amazon SQS) and inserts them to Amazon DynamoDB using SAM and .NET 8", "content_language": "English", "language": ".NET", "type": ["Unit", "Integration"], diff --git a/dotnet-test-samples/test-containers/README.md b/dotnet-test-samples/test-containers/README.md index b9b177ec..91ca301d 100644 --- a/dotnet-test-samples/test-containers/README.md +++ b/dotnet-test-samples/test-containers/README.md @@ -10,7 +10,7 @@ ### Description -This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 6. It also demonstrates how you can use a local emulated version of DynamoDB to increase the speed of feedback loops as you make changes to your application code. +This pattern creates an Amazon API Gateway HTTP API, an AWS Lambda function, and a DynamoDB Table using SAM and .NET 8. It also demonstrates how you can use a local emulated version of DynamoDB to increase the speed of feedback loops as you make changes to your application code. Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage. Please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. @@ -260,7 +260,7 @@ sam delete * [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured * [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) * [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed -* [.NET 6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed +* [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet) installed * The ability to run Docker containers ## Video Walkthroughs diff --git a/dotnet-test-samples/test-containers/src/DeleteProduct/aws-lambda-tools-defaults.json b/dotnet-test-samples/test-containers/src/DeleteProduct/aws-lambda-tools-defaults.json index e21ca34d..580dc7a9 100644 --- a/dotnet-test-samples/test-containers/src/DeleteProduct/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/test-containers/src/DeleteProduct/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "DeleteProduct::DeleteProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/test-containers/src/GetProducts/GetProducts.csproj b/dotnet-test-samples/test-containers/src/GetProducts/GetProducts.csproj index ab239a48..7ad2457b 100644 --- a/dotnet-test-samples/test-containers/src/GetProducts/GetProducts.csproj +++ b/dotnet-test-samples/test-containers/src/GetProducts/GetProducts.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 true true true diff --git a/dotnet-test-samples/test-containers/src/GetProducts/aws-lambda-tools-defaults.json b/dotnet-test-samples/test-containers/src/GetProducts/aws-lambda-tools-defaults.json index 2bc3d241..f2b841fb 100644 --- a/dotnet-test-samples/test-containers/src/GetProducts/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/test-containers/src/GetProducts/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "GetProducts::GetProducts.Function::FunctionHandler" diff --git a/dotnet-test-samples/test-containers/src/PutProduct/aws-lambda-tools-defaults.json b/dotnet-test-samples/test-containers/src/PutProduct/aws-lambda-tools-defaults.json index 38672a3f..9fe5013c 100644 --- a/dotnet-test-samples/test-containers/src/PutProduct/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/test-containers/src/PutProduct/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "PutProduct::PutProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi/aws-lambda-tools-defaults.json b/dotnet-test-samples/test-containers/src/ServerlessTestApi/aws-lambda-tools-defaults.json index 67fdd408..02bb3dc5 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi/aws-lambda-tools-defaults.json +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi/aws-lambda-tools-defaults.json @@ -9,7 +9,7 @@ "region": "", "configuration": "Release", "function-architecture": "x86_64", - "function-runtime": "dotnet6", + "function-runtime": "dotnet8", "function-memory-size": 256, "function-timeout": 30, "function-handler": "GetProduct::GetProduct.Function::FunctionHandler" diff --git a/dotnet-test-samples/test-containers/src/ServerlessTestApi/serverless.template b/dotnet-test-samples/test-containers/src/ServerlessTestApi/serverless.template index 3991e0fe..297a5c76 100644 --- a/dotnet-test-samples/test-containers/src/ServerlessTestApi/serverless.template +++ b/dotnet-test-samples/test-containers/src/ServerlessTestApi/serverless.template @@ -12,7 +12,7 @@ ] }, "Properties": { - "Runtime": "dotnet6", + "Runtime": "dotnet8", "CodeUri": ".", "MemorySize": 256, "Timeout": 30, @@ -41,7 +41,7 @@ ] }, "Properties": { - "Runtime": "dotnet6", + "Runtime": "dotnet8", "CodeUri": ".", "MemorySize": 256, "Timeout": 30, @@ -70,7 +70,7 @@ ] }, "Properties": { - "Runtime": "dotnet6", + "Runtime": "dotnet8", "CodeUri": ".", "MemorySize": 256, "Timeout": 30, @@ -99,7 +99,7 @@ ] }, "Properties": { - "Runtime": "dotnet6", + "Runtime": "dotnet8", "CodeUri": ".", "MemorySize": 256, "Timeout": 30, From 57c26e11c0af11cc6308027723ca84da6e75b4c3 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Thu, 1 Aug 2024 12:20:15 +0300 Subject: [PATCH 5/6] Update dotnet.yml with new build actions and .NET 8 --- .github/workflows/dotnet.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 9e1fd61f..7b62de29 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -19,11 +19,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.x + dotnet-version: | + 6.0.x + 8.0.x - name: Build run: find dotnet-test-samples -name "*.sln" -exec dotnet build {} \; From 5eafcb4c14c76a0abd9c2b43d27dc1d891e7a3d1 Mon Sep 17 00:00:00 2001 From: Dror Helper Date: Thu, 1 Aug 2024 17:42:12 +0300 Subject: [PATCH 6/6] Removed load test untli content is found --- dotnet-test-samples/load-testing/README.md | 23 ------------------- .../load-testing/loadtest/loadtest.yml | 13 ----------- .../load-testing/loadtest/run-load-test.ps1 | 8 ------- .../load-testing/loadtest/run-load-test.sh | 8 ------- 4 files changed, 52 deletions(-) delete mode 100644 dotnet-test-samples/load-testing/README.md delete mode 100644 dotnet-test-samples/load-testing/loadtest/loadtest.yml delete mode 100644 dotnet-test-samples/load-testing/loadtest/run-load-test.ps1 delete mode 100644 dotnet-test-samples/load-testing/loadtest/run-load-test.sh diff --git a/dotnet-test-samples/load-testing/README.md b/dotnet-test-samples/load-testing/README.md deleted file mode 100644 index 9985b73b..00000000 --- a/dotnet-test-samples/load-testing/README.md +++ /dev/null @@ -1,23 +0,0 @@ -[![.NET: 8.0](https://img.shields.io/badge/.NET-8.0-Green)](https://img.shields.io/badge/.NET-6.0-Green) -[![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)](https://img.shields.io/badge/AWS-Lambda-blueviolet) -[![test: unit](https://img.shields.io/badge/Test-Unit-blue)](https://img.shields.io/badge/Test-Unit-blue) -[![test: integration](https://img.shields.io/badge/Test-Integration-yellow)](https://img.shields.io/badge/Test-Integration-yellow) - -# Load Testing - -## Perform a load test -Load tests should be executed in the cloud prior to any initial deployment to production environments. Load tests can be useful to discover performance bottlenecks and quota limits. Load tests should be scripted and repeatable. Load tests should simulate your application's expected peak load. - -[Artillery](https://www.artillery.io/) is used for load testing. Load tests scenarios are configured using a yaml configuration file. The configured load tests runs 100 requests / second for 10 minutes to our API endpoints. - -To execute the load tests run either the PowerShell or bash scripts under the [load test directory](./loadtest). - -```bash -cd loadtest -./run-load-test.sh -``` - -```powershell -cd loadtest -./run-load-test.ps1 -``` \ No newline at end of file diff --git a/dotnet-test-samples/load-testing/loadtest/loadtest.yml b/dotnet-test-samples/load-testing/loadtest/loadtest.yml deleted file mode 100644 index d814872c..00000000 --- a/dotnet-test-samples/load-testing/loadtest/loadtest.yml +++ /dev/null @@ -1,13 +0,0 @@ -config: - target: "{{ $processEnvironment.API_URL }}" - http: - timeout : 60 - phases: - - duration: 600 - arrivalRate: 100 - -scenarios: - - name: "List buckets" - flow: - - get: - url: "/" \ No newline at end of file diff --git a/dotnet-test-samples/load-testing/loadtest/run-load-test.ps1 b/dotnet-test-samples/load-testing/loadtest/run-load-test.ps1 deleted file mode 100644 index 27c89797..00000000 --- a/dotnet-test-samples/load-testing/loadtest/run-load-test.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$STACK_NAME = "dotnet-test-samples" -$REGION= "us-east-1" -Write-Output "Retrieving API Url from CloudFormation stack" -$API_URL = (aws cloudformation describe-stacks --stack-name $STACK_NAME --region $REGION --query 'Stacks[0].Outputs[?OutputKey==`HelloWorldApi`].OutputValue' --output text) -Write-Output "API Url found" -Write-Output $API_URL -Write-Output "Running load test" -artillery run loadtest.yml --target "$API_URL" \ No newline at end of file diff --git a/dotnet-test-samples/load-testing/loadtest/run-load-test.sh b/dotnet-test-samples/load-testing/loadtest/run-load-test.sh deleted file mode 100644 index b7598f41..00000000 --- a/dotnet-test-samples/load-testing/loadtest/run-load-test.sh +++ /dev/null @@ -1,8 +0,0 @@ -STACK_NAME=dotnet-test-samples -REGION=us-east-1 - -API_URL=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --region $REGION \ - --query 'Stacks[0].Outputs[?OutputKey==`HelloWorldApi`].OutputValue' \ - --output text) - -artillery run load-test.yml --target "$API_URL" \ No newline at end of file