-
Notifications
You must be signed in to change notification settings - Fork 7
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 shugaoye/master
Release 1.0.0
- Loading branch information
Showing
154 changed files
with
13,949 additions
and
259 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,69 @@ | ||
name: PassXYZ.Vault CI Build (MacOS) | ||
|
||
on: | ||
push: | ||
branches: [ chapter12 ] | ||
paths-ignore: | ||
- '**/*.md' | ||
- '**/*.gitignore' | ||
- '**/*.gitattributes' | ||
pull_request: | ||
branches: [ chapter12 ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
DOTNET_NOLOGO: true # Disable the .NET logo | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience | ||
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry | ||
DOTNETVERSION: 6.0.x | ||
PROJECT_NAME: PassXYZ.Vault | ||
|
||
jobs: | ||
# MAUI iOS Build | ||
build-ios: | ||
runs-on: macos-latest | ||
name: iOS Build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{env.DOTNETVERSION}} | ||
- name: Install MAUI workload | ||
run: dotnet workload install maui | ||
- name: Restore Dependencies | ||
run: dotnet restore ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj | ||
- name: Build MAUI iOS | ||
run: dotnet build ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj -c Release -f net6.0-ios --no-restore /p:buildForSimulator=True /p:packageApp=True /p:ArchiveOnBuild=False | ||
- name: Upload iOS Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: passxyz-ios-ci-build | ||
path: ${{env.PROJECT_NAME}}/bin/Release/net6.0-ios/iossimulator-x64/**/*.app | ||
|
||
# MAUI MacCatalyst Build | ||
build-mac: | ||
runs-on: macos-latest | ||
name: MacCatalyst Build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{env.DOTNETVERSION}} | ||
- name: Install MAUI workload | ||
run: dotnet workload install maui | ||
- name: Restore Dependencies | ||
run: dotnet restore ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj | ||
- name: Build MAUI MacCatalyst | ||
run: dotnet publish ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj -c Release -f net6.0-maccatalyst --no-restore -p:BuildIpa=True | ||
- name: Upload MacCatalyst Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: passxyz-macos-ci-build | ||
path: ${{env.PROJECT_NAME}}/bin/Release/net6.0-maccatalyst/maccatalyst-x64/publish/*.pkg |
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,74 @@ | ||
name: PassXYZ.Vault CI Build (Windows) | ||
|
||
on: | ||
push: | ||
branches: [ chapter12 ] | ||
paths-ignore: | ||
- '**/*.md' | ||
- '**/*.gitignore' | ||
- '**/*.gitattributes' | ||
pull_request: | ||
branches: [ chapter12 ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
DOTNET_NOLOGO: true # Disable the .NET logo | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience | ||
DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry | ||
DOTNETVERSION: 6.0.x | ||
PROJECT_NAME: PassXYZ.Vault | ||
|
||
jobs: | ||
# MAUI Android Build | ||
build-android: | ||
runs-on: windows-latest | ||
name: Android Build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{env.DOTNETVERSION}} | ||
- name: Install MAUI workload | ||
run: dotnet workload install maui | ||
- name: Restore Dependencies | ||
run: dotnet restore ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj | ||
|
||
- name: Build MAUI Android | ||
run: dotnet publish ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj -c Release -f net6.0-android --no-restore | ||
|
||
- name: Upload Android Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: passxyz-android-ci-build | ||
path: ${{env.PROJECT_NAME}}/bin/Release/net6.0-android/*Signed.a* | ||
|
||
# MAUI Windows Build | ||
build-windows: | ||
runs-on: windows-latest | ||
name: Windows Build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{env.DOTNETVERSION}} | ||
- name: Install MAUI workload | ||
run: dotnet workload install maui | ||
- name: Restore Dependencies | ||
run: dotnet restore ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj | ||
|
||
- name: Build MAUI Windows | ||
run: dotnet publish ${{env.PROJECT_NAME}}/${{env.PROJECT_NAME}}.csproj -c Release -f net6.0-windows10.0.19041.0 --no-restore | ||
|
||
- name: Upload Windows Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: passxyz-windows-ci-build | ||
path: ${{env.PROJECT_NAME}}/bin/Release/net6.0-windows10.0.19041.0/win10-x64/AppPackages/${{env.PROJECT_NAME}}*/${{env.PROJECT_NAME}}*.msix | ||
|
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,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<UseMaui>true</UseMaui> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="NSubstitute" Version="4.3.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" /> | ||
<PackageReference Include="PassXYZLib" Version="2.1.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\PassXYZ.Vault\PassXYZ.Vault.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
using KPCLib; | ||
using PassXYZ.Vault.Services; | ||
using PassXYZLib; | ||
|
||
namespace PassXYZ.Vault.Tests.Services | ||
{ | ||
[CollectionDefinition("Non-Parallel Collection", DisableParallelization = true)] | ||
public class NonParallelCollectionDefinitionClass | ||
{ | ||
} | ||
|
||
[Collection("Non-Parallel Collection")] | ||
public class IDataStoreTest | ||
{ | ||
readonly IDataStore<Item> dataStore; | ||
User _user; | ||
public IDataStoreTest() | ||
{ | ||
dataStore = new DataStore(); | ||
_user = new User | ||
{ | ||
Username = "test1", | ||
Password = "12345" | ||
}; | ||
} | ||
|
||
[Fact] | ||
public async void GetItemsAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
var items = await dataStore.GetItemsAsync(true); | ||
Assert.NotEmpty(items); | ||
} | ||
|
||
[Fact] | ||
public async void AddGroupAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxGroup() | ||
{ | ||
Name = "New Group 1", | ||
Notes = "This is a new group." | ||
}; | ||
result = await dataStore.AddItemAsync(newItem); | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public async void AddEntryAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxEntry() | ||
{ | ||
Name = "New Entry 1", | ||
Notes = "This is a new entry." | ||
}; | ||
result = await dataStore.AddItemAsync(newItem); | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public async void AddItemAsyncFailureTest() | ||
{ | ||
bool result = false; | ||
#pragma warning disable CS8625 // Possible null reference argument. | ||
var ex = await Assert.ThrowsAsync<ArgumentNullException>(async () => result = await dataStore.AddItemAsync(null)); | ||
#pragma warning restore CS8625 // Possible null reference argument. | ||
Assert.Equal("Value cannot be null. (Parameter 'item')", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public async void UpdateItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxEntry() | ||
{ | ||
Name = "New item 1", | ||
Notes = "This is a new item." | ||
}; | ||
result = await dataStore.AddItemAsync(newItem); | ||
Assert.True(result); | ||
newItem.Name = "Updated item 1"; | ||
result = await dataStore.UpdateItemAsync(newItem); | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public async void UpdateNullItemAsyncTest() | ||
{ | ||
bool result = false; | ||
#pragma warning disable CS8625 // Possible null reference argument. | ||
var ex = await Assert.ThrowsAsync<ArgumentNullException>(async () => result = await dataStore.UpdateItemAsync(null)); | ||
#pragma warning restore CS8625 // Possible null reference argument. | ||
Assert.Equal("Value cannot be null. (Parameter 'item')", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public async void UpdateNoExistItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new NewItem() | ||
{ | ||
Name = "No item 1", | ||
Notes = "You cannot find this item." | ||
}; | ||
result = await dataStore.UpdateItemAsync(newItem); | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public async void DeleteItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxEntry() | ||
{ | ||
Name = "New item 1", | ||
Notes = "Please delete it." | ||
}; | ||
result = await dataStore.AddItemAsync(newItem); | ||
Assert.True(result); | ||
result = await dataStore.DeleteItemAsync(newItem.Id); | ||
Assert.True(result); | ||
} | ||
|
||
[Fact] | ||
public async void DeleteNullItemAsyncTest() | ||
{ | ||
bool result = false; | ||
#pragma warning disable CS8625 // Possible null reference argument. | ||
var ex = await Assert.ThrowsAsync<ArgumentNullException>(async () => result = await dataStore.DeleteItemAsync(null)); | ||
#pragma warning restore CS8625 // Possible null reference argument. | ||
Assert.Equal("Value cannot be null. (Parameter 'id')", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public async void DeleteNoExistItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxEntry() | ||
{ | ||
Name = "No item 1", | ||
Notes = "You cannot find this item." | ||
}; | ||
result = await dataStore.DeleteItemAsync(newItem.Id); | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public async void GetItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new PxEntry() | ||
{ | ||
Name = "New item 1", | ||
Notes = "This is a new item." | ||
}; | ||
result = await dataStore.AddItemAsync(newItem); | ||
Assert.True(result); | ||
var item = dataStore.GetItem(newItem.Id); | ||
Assert.NotNull(item); | ||
Assert.Equal(newItem.Name, item.Name); | ||
} | ||
|
||
[Fact] | ||
public async void GetNullItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
#pragma warning disable CS8625 // Possible null reference argument. | ||
var ex = Assert.Throws<ArgumentNullException>(() => dataStore.GetItem(null)); | ||
#pragma warning restore CS8625 // Possible null reference argument. | ||
Assert.Equal("Value cannot be null. (Parameter 'id')", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public async void GetNoExistItemAsyncTest() | ||
{ | ||
bool result = await dataStore.ConnectAsync(_user); | ||
Assert.True(result); | ||
dataStore.SetCurrentGroup(); | ||
|
||
Item newItem = new NewItem() | ||
{ | ||
Name = "No item 1", | ||
Notes = "You cannot find this item." | ||
}; | ||
var item = dataStore.GetItem(newItem.Id); | ||
Assert.Null(item); | ||
} | ||
} | ||
} |
Oops, something went wrong.