Skip to content

Commit

Permalink
Admin: Add DotNet tests for SQS
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers committed Nov 16, 2024
1 parent 10bdd08 commit d521ef8
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests_sdk_dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ jobs:
- 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 d521ef8

Please sign in to comment.