Skip to content

Commit

Permalink
Admin: Add DotNet tests for SQS (#8323)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Nov 16, 2024
1 parent 10bdd08 commit 114e344
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests_sdk_dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
39 changes: 39 additions & 0 deletions other_langs/tests_dotnet/sqs/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -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<CreateQueueResponse> CreateQueueAsync(AmazonSQSClient sqsClient)
{
var createQueueRequest = new CreateQueueRequest
{
QueueName = "MyQueue"
};

return await sqsClient.CreateQueueAsync(createQueueRequest);
}

}
1 change: 1 addition & 0 deletions other_langs/tests_dotnet/sqs/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
26 changes: 26 additions & 0 deletions other_langs/tests_dotnet/sqs/sqs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>

<UserSecretsId>45a910a7-aba2-43ee-ad3c-ccad57f044d9</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="3.7.200" />
<PackageReference Include="FluentAssertions" Version="6.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>

0 comments on commit 114e344

Please sign in to comment.