Admin: DotNet example project (#6110)
This commit is contained in:
parent
588dd58b37
commit
98b02fc1a3
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@ -74,6 +74,10 @@ jobs:
|
||||
needs: lint
|
||||
uses: ./.github/workflows/tests_sdk_java.yml
|
||||
|
||||
dotnettest:
|
||||
needs: lint
|
||||
uses: ./.github/workflows/tests_sdk_dotnet.yml
|
||||
|
||||
test:
|
||||
needs: [lint]
|
||||
uses: ./.github/workflows/tests_decoratormode.yml
|
||||
@ -85,7 +89,7 @@ jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [javatest, test, testserver ]
|
||||
needs: [dotnettest, javatest, test, testserver ]
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'getmoto/moto' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
35
.github/workflows/tests_sdk_dotnet.yml
vendored
Normal file
35
.github/workflows/tests_sdk_dotnet.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: .NET SDK test
|
||||
on: [workflow_call]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.8"
|
||||
- name: Start MotoServer
|
||||
run: |
|
||||
pip install build
|
||||
python -m build
|
||||
docker run --rm -t --name motoserver -e TEST_SERVER_MODE=true -e AWS_SECRET_ACCESS_KEY=server_secret -e AWS_ACCESS_KEY_ID=server_key -v `pwd`:/moto -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock python:3.7-buster /moto/scripts/ci_moto_server.sh &
|
||||
python scripts/ci_wait_for_server.py
|
||||
- uses: actions/setup-dotnet@v3
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
# Look to see if there is a cache hit for the corresponding requirements file
|
||||
key: ${{ runner.os }}-nuget
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nuget
|
||||
- name: Install dependencies
|
||||
run: cd other_langs/tests_dotnet && dotnet restore ExampleTestProject/
|
||||
- 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/
|
2
.github/workflows/tests_sdk_java.yml
vendored
2
.github/workflows/tests_sdk_java.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.8"
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,3 +31,5 @@ docs/_build
|
||||
moto_recording
|
||||
.hypothesis
|
||||
other_langs/tests_java/target
|
||||
other_langs/tests_dotnet/ExampleTestProject/bin
|
||||
other_langs/tests_dotnet/ExampleTestProject/obj
|
||||
|
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.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.S3" Version="3.7.103.34" />
|
||||
<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>
|
35
other_langs/tests_dotnet/ExampleTestProject/UnitTest.cs
Normal file
35
other_langs/tests_dotnet/ExampleTestProject/UnitTest.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using FluentAssertions;
|
||||
using System.Net;
|
||||
|
||||
// To interact with Amazon S3.
|
||||
using Amazon.S3;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public async Task TestListBuckets()
|
||||
{
|
||||
|
||||
AmazonS3Config config = new AmazonS3Config()
|
||||
{
|
||||
ServiceURL = "http://localhost:5000",
|
||||
};
|
||||
|
||||
AmazonS3Client s3Client = new AmazonS3Client(config);
|
||||
|
||||
var initial_list = await s3Client.ListBucketsAsync();
|
||||
initial_list.Buckets.Count.Should().Be(0);
|
||||
|
||||
var putBucketRequest = new PutBucketRequest
|
||||
{
|
||||
BucketName = "MyFirstBucket",
|
||||
UseClientRegion = true
|
||||
};
|
||||
await s3Client.PutBucketAsync(putBucketRequest);
|
||||
|
||||
var listResponse = await s3Client.ListBucketsAsync();
|
||||
listResponse.Buckets.Count.Should().Be(1);
|
||||
}
|
||||
}
|
1
other_langs/tests_dotnet/ExampleTestProject/Usings.cs
Normal file
1
other_langs/tests_dotnet/ExampleTestProject/Usings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using Xunit;
|
Loading…
Reference in New Issue
Block a user