From cba36e2e0058164b5d46cbc706e3d76affe838d8 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Sat, 16 Nov 2024 12:21:13 -0100 Subject: [PATCH] Admin: Add DotNet tests for SQS --- .github/workflows/tests_sdk_dotnet.yml | 6 ++- .../{ExampleTestProject => s3}/UnitTest.cs | 0 .../{ExampleTestProject => s3}/Usings.cs | 0 .../s3.csproj} | 2 +- other_langs/tests_dotnet/sqs/UnitTest.cs | 39 +++++++++++++++++++ other_langs/tests_dotnet/sqs/Usings.cs | 1 + other_langs/tests_dotnet/sqs/sqs.csproj | 26 +++++++++++++ 7 files changed, 71 insertions(+), 3 deletions(-) rename other_langs/tests_dotnet/{ExampleTestProject => s3}/UnitTest.cs (100%) rename other_langs/tests_dotnet/{ExampleTestProject => s3}/Usings.cs (100%) rename other_langs/tests_dotnet/{ExampleTestProject/ExampleTestProject.csproj => s3/s3.csproj} (95%) create mode 100644 other_langs/tests_dotnet/sqs/UnitTest.cs create mode 100644 other_langs/tests_dotnet/sqs/Usings.cs create mode 100644 other_langs/tests_dotnet/sqs/sqs.csproj diff --git a/.github/workflows/tests_sdk_dotnet.yml b/.github/workflows/tests_sdk_dotnet.yml index fe4d656b12d..2abc437484c 100644 --- a/.github/workflows/tests_sdk_dotnet.yml +++ b/.github/workflows/tests_sdk_dotnet.yml @@ -28,8 +28,10 @@ jobs: restore-keys: | ${{ runner.os }}-nuget - name: Install dependencies - run: cd other_langs/tests_dotnet && dotnet restore ExampleTestProject/ && dotnet restore ebs + run: cd other_langs/tests_dotnet && dotnet restore s3 && dotnet restore sqs - name: Run tests run: | mkdir ~/.aws && touch ~/.aws/credentials && echo -e "[default]\naws_access_key_id = test\naws_secret_access_key = test" > ~/.aws/credentials - cd other_langs/tests_dotnet && dotnet test ExampleTestProject/ && dotnet restore ebs + cd other_langs/tests_dotnet + dotnet test s3 -v n + dotnet test sqs -v n diff --git a/other_langs/tests_dotnet/ExampleTestProject/UnitTest.cs b/other_langs/tests_dotnet/s3/UnitTest.cs similarity index 100% rename from other_langs/tests_dotnet/ExampleTestProject/UnitTest.cs rename to other_langs/tests_dotnet/s3/UnitTest.cs diff --git a/other_langs/tests_dotnet/ExampleTestProject/Usings.cs b/other_langs/tests_dotnet/s3/Usings.cs similarity index 100% rename from other_langs/tests_dotnet/ExampleTestProject/Usings.cs rename to other_langs/tests_dotnet/s3/Usings.cs diff --git a/other_langs/tests_dotnet/ExampleTestProject/ExampleTestProject.csproj b/other_langs/tests_dotnet/s3/s3.csproj similarity index 95% rename from other_langs/tests_dotnet/ExampleTestProject/ExampleTestProject.csproj rename to other_langs/tests_dotnet/s3/s3.csproj index ebda95cc3d7..92932de668a 100644 --- a/other_langs/tests_dotnet/ExampleTestProject/ExampleTestProject.csproj +++ b/other_langs/tests_dotnet/s3/s3.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 enable enable diff --git a/other_langs/tests_dotnet/sqs/UnitTest.cs b/other_langs/tests_dotnet/sqs/UnitTest.cs new file mode 100644 index 00000000000..b5ade6bd8a1 --- /dev/null +++ b/other_langs/tests_dotnet/sqs/UnitTest.cs @@ -0,0 +1,39 @@ +using FluentAssertions; +using System.Net; + +// To interact with Amazon S3. +using Amazon.SQS; +using Amazon.SQS.Model; + +public class UnitTest1 +{ + + [Fact] + public async Task TestCreateQueue() + { + + // Create an SQS client connected to the local moto server + var sqsClient = new AmazonSQSClient( + new AmazonSQSConfig + { + // Use the local Moto server URL + ServiceURL = "http://127.0.0.1:5000", + + }); + + // Create the queue and get the response + var createQueueResponse = await CreateQueueAsync(sqsClient); + createQueueResponse.QueueUrl.Should().Be("http://127.0.0.1:5000/123456789012/MyQueue"); + } + + private static async Task CreateQueueAsync(AmazonSQSClient sqsClient) + { + var createQueueRequest = new CreateQueueRequest + { + QueueName = "MyQueue" + }; + + return await sqsClient.CreateQueueAsync(createQueueRequest); + } + +} \ No newline at end of file diff --git a/other_langs/tests_dotnet/sqs/Usings.cs b/other_langs/tests_dotnet/sqs/Usings.cs new file mode 100644 index 00000000000..8c927eb747a --- /dev/null +++ b/other_langs/tests_dotnet/sqs/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/other_langs/tests_dotnet/sqs/sqs.csproj b/other_langs/tests_dotnet/sqs/sqs.csproj new file mode 100644 index 00000000000..cab1d3da319 --- /dev/null +++ b/other_langs/tests_dotnet/sqs/sqs.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + + true + true + + 45a910a7-aba2-43ee-ad3c-ccad57f044d9 + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + +