Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin: Add DotNet tests for SQS #8323

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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>
Loading