-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from reown-com/chore/tests
chore: improve tests
- Loading branch information
Showing
18 changed files
with
267 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: 'test-dotnet' | ||
description: 'Runs unit and integration tests with dotnet cli' | ||
|
||
inputs: | ||
type: | ||
description: 'The type of CI step to run' | ||
required: true | ||
relay-endpoint: | ||
description: 'The endpoint of the relay e.g. wss://relay.walletconnect.org' | ||
required: false | ||
default: 'wss://relay.walletconnect.org' | ||
project-id: | ||
description: 'Reown project id' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Run tests | ||
if: inputs.type == 'unit-tests' | ||
shell: bash | ||
run: dotnet test Reown.NoUnity.slnf --verbosity minimal --filter Category=unit | ||
|
||
- name: Run integration tests | ||
if: inputs.type == 'integration-tests' | ||
shell: bash | ||
env: | ||
RELAY_ENDPOINT: ${{ inputs.relay-endpoint }} | ||
PROJECT_ID: ${{ inputs.project-id }} | ||
run: dotnet test Reown.NoUnity.slnf --verbosity minimal --filter Category=integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: .NET Build & Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
working-directory: ./ | ||
|
||
- name: Build | ||
run: dotnet build Reown.NoUnity.slnf --no-restore | ||
working-directory: ./ | ||
|
||
test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
test-type: [unit-tests, integration-tests] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
8.0.x | ||
- name: Run tests | ||
uses: ./.github/actions/test-dotnet | ||
with: | ||
type: ${{ matrix.test-type }} | ||
project-id: ${{ secrets.PROJECT_ID }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"solution": { | ||
"path": "Reown.sln", | ||
"projects": [ | ||
"src\\Reown.Core.Common\\Reown.Core.Common.csproj", | ||
"src\\Reown.Core.Crypto\\Reown.Core.Crypto.csproj", | ||
"src\\Reown.Core.Network.WebSocket\\Reown.Core.Network.WebSocket.csproj", | ||
"src\\Reown.Core.Network\\Reown.Core.Network.csproj", | ||
"src\\Reown.Core.Storage\\Reown.Core.Storage.csproj", | ||
"src\\Reown.Core\\Reown.Core.csproj", | ||
"src\\Reown.Sign.Nethereum\\Reown.Sign.Nethereum.csproj", | ||
"src\\Reown.Sign\\Reown.Sign.csproj", | ||
"src\\Reown.WalletKit\\Reown.WalletKit.csproj", | ||
"test\\Reown.Core.Crypto.Test\\Reown.Core.Crypto.Test.csproj", | ||
"test\\Reown.Core.Network.Test\\Reown.Core.Network.Test.csproj", | ||
"test\\Reown.Core.Storage.Test\\Reown.Core.Storage.Test.csproj", | ||
"test\\Reown.Sign.Test\\Reown.Sign.Test.csproj", | ||
"test\\Reown.WalletKit.Test\\Reown.WalletKit.Test.csproj", | ||
"test\\Rown.TestUtils\\Rown.TestUtils.csproj" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Reown.TestUtils; | ||
using Xunit; | ||
|
||
namespace Reown.Core.Storage.Test; | ||
|
||
public class FileSystemStorageTest | ||
{ | ||
[Fact] [Trait("Category", "unit")] | ||
public async Task GetSetRemoveTest() | ||
{ | ||
using var tempFolder = new TempFolder(); | ||
var testDictStorage = new FileSystemStorage(Path.Combine(tempFolder.Folder.FullName, ".wctestdata")); | ||
await testDictStorage.Init(); | ||
await testDictStorage.SetItem("somekey", "somevalue"); | ||
Assert.Equal("somevalue", await testDictStorage.GetItem<string>("somekey")); | ||
await testDictStorage.RemoveItem("somekey"); | ||
await Assert.ThrowsAsync<KeyNotFoundException>(() => testDictStorage.GetItem<string>("somekey")); | ||
} | ||
|
||
private static readonly string[] expected = new string[] | ||
{ | ||
"addkey" | ||
}; | ||
|
||
[Fact] [Trait("Category", "unit")] | ||
public async Task GetKeysTest() | ||
{ | ||
using var tempFolder = new TempFolder(); | ||
var testDictStorage = new FileSystemStorage(Path.Combine(tempFolder.Folder.FullName, ".wctestdata")); | ||
await testDictStorage.Init(); | ||
await testDictStorage.Clear(); //Clear any persistant state | ||
await testDictStorage.SetItem("addkey", "testingvalue"); | ||
Assert.Equal(expected, await testDictStorage.GetKeys()); | ||
} | ||
|
||
[Fact] [Trait("Category", "unit")] | ||
public async Task GetEntriesTests() | ||
{ | ||
using var tempFolder = new TempFolder(); | ||
var testDictStorage = new FileSystemStorage(Path.Combine(tempFolder.Folder.FullName, ".wctestdata")); | ||
await testDictStorage.Init(); | ||
await testDictStorage.Clear(); | ||
await testDictStorage.SetItem("addkey", "testingvalue"); | ||
Assert.Equal([ | ||
"testingvalue" | ||
], await testDictStorage.GetEntries()); | ||
await testDictStorage.SetItem("newkey", 5); | ||
Assert.Equal(new int[] | ||
{ | ||
5 | ||
}, await testDictStorage.GetEntriesOfType<int>()); | ||
} | ||
|
||
[Fact] [Trait("Category", "unit")] | ||
public async Task HasItemTest() | ||
{ | ||
using var tempFolder = new TempFolder(); | ||
var testDictStorage = new FileSystemStorage(Path.Combine(tempFolder.Folder.FullName, ".wctestdata")); | ||
await testDictStorage.Init(); | ||
await testDictStorage.SetItem("checkedkey", "testingvalue"); | ||
Assert.True(await testDictStorage.HasItem("checkedkey")); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/Reown.Core.Storage.Test/Reown.Core.Storage.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk"/> | ||
<PackageReference Include="xunit"/> | ||
<PackageReference Include="xunit.runner.visualstudio"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Reown.Core.Storage\Reown.Core.Storage.csproj" /> | ||
<ProjectReference Include="..\Rown.TestUtils\Rown.TestUtils.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters