-
-
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.
* Add Feature Settings Cache * Update GetOrCreateObject * Fix code warnings
- Loading branch information
1 parent
a7a4782
commit b384814
Showing
17 changed files
with
786 additions
and
8 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
32 changes: 32 additions & 0 deletions
32
...base.EncryptedSettings.Tests/ReactiveMarbles.CacheDatabase.EncryptedSettings.Tests.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,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<DefineConstants>ENCRYPTED</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\ReactiveMarbles.CacheDatabase.Settings.Tests\Mocks\*.cs" LinkBase="Mocks" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<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> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveMarbles.CacheDatabase.EncryptedSettings\ReactiveMarbles.CacheDatabase.EncryptedSettings.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
47 changes: 47 additions & 0 deletions
47
src/ReactiveMarbles.CacheDatabase.EncryptedSettings.Tests/SettingsCacheTests.cs
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,47 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
using ReactiveMarbles.CacheDatabase.Settings.Tests; | ||
|
||
namespace ReactiveMarbles.CacheDatabase.EncryptedSettings.Tests | ||
{ | ||
/// <summary> | ||
/// Settings Cache Tests. | ||
/// </summary> | ||
public class SettingsCacheTests | ||
{ | ||
/// <summary> | ||
/// Test1s this instance. | ||
/// </summary> | ||
[Fact] | ||
public async void TestCreateAndInsert() | ||
{ | ||
await AppInfo.DeleteSettingsStore<ViewSettings>(); | ||
var viewSettings = await AppInfo.SetupSettingsStore<ViewSettings>("test1234"); | ||
|
||
Assert.NotNull(viewSettings); | ||
Assert.True(viewSettings!.BoolTest); | ||
Assert.Equal((short)16, viewSettings.ShortTest); | ||
Assert.Equal(1, viewSettings.IntTest); | ||
Assert.Equal(123456L, viewSettings.LongTest); | ||
Assert.Equal("TestString", viewSettings.StringTest); | ||
Assert.Equal(2.2f, viewSettings.FloatTest); | ||
Assert.Equal(23.8d, viewSettings.DoubleTest); | ||
Assert.Equal(EnumTestValue.Option1, viewSettings.EnumTest); | ||
await viewSettings.DisposeAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests the update and read. | ||
/// </summary> | ||
[Fact] | ||
public async void TestUpdateAndRead() | ||
{ | ||
var viewSettings = await AppInfo.SetupSettingsStore<ViewSettings>("test1234"); | ||
viewSettings!.EnumTest = EnumTestValue.Option2; | ||
Assert.Equal(EnumTestValue.Option2, viewSettings.EnumTest); | ||
await viewSettings.DisposeAsync(); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/ReactiveMarbles.CacheDatabase.EncryptedSettings.Tests/Usings.cs
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,5 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
global using Xunit; |
22 changes: 22 additions & 0 deletions
22
...es.CacheDatabase.EncryptedSettings/ReactiveMarbles.CacheDatabase.EncryptedSettings.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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>ReactiveMarbles.CacheDatabase.EncryptedSettings</RootNamespace> | ||
<LangVersion>preview</LangVersion> | ||
<DefineConstants>ENCRYPTED</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\ReactiveMarbles.CacheDatabase.Settings\Core\*.cs" LinkBase="Core" /> | ||
<Compile Include="..\ReactiveMarbles.CacheDatabase.Settings\SettingsBase.cs" Link="SettingsBase.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveMarbles.CacheDatabase.EncryptedSqlite3\ReactiveMarbles.CacheDatabase.EncryptedSqlite3.csproj" /> | ||
<ProjectReference Include="..\ReactiveMarbles.CacheDatabase.NewtonsoftJson\ReactiveMarbles.CacheDatabase.NewtonsoftJson.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
34 changes: 34 additions & 0 deletions
34
src/ReactiveMarbles.CacheDatabase.Settings.Tests/Mocks/EnumTestValue.cs
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,34 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
namespace ReactiveMarbles.CacheDatabase.Settings.Tests | ||
{ | ||
|
||
/// <summary> | ||
/// EnumTestValue. | ||
/// </summary> | ||
public enum EnumTestValue | ||
{ | ||
/// <summary> | ||
/// The default. | ||
/// </summary> | ||
Default, | ||
/// <summary> | ||
/// The option1. | ||
/// </summary> | ||
Option1, | ||
/// <summary> | ||
/// The option2. | ||
/// </summary> | ||
Option2, | ||
/// <summary> | ||
/// The option3. | ||
/// </summary> | ||
Option3, | ||
/// <summary> | ||
/// The option4. | ||
/// </summary> | ||
Option4, | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
src/ReactiveMarbles.CacheDatabase.Settings.Tests/Mocks/ViewSettings.cs
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,120 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
namespace ReactiveMarbles.CacheDatabase.Settings.Tests | ||
{ | ||
/// <summary> | ||
/// View Settings. | ||
/// </summary> | ||
/// <seealso cref="ReactiveMarbles.CacheDatabase.Settings.SettingsBase" /> | ||
public class ViewSettings : SettingsBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ViewSettings"/> class. | ||
/// </summary> | ||
public ViewSettings() | ||
: base(nameof(ViewSettings)) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether [bool test]. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if [bool test]; otherwise, <c>false</c>. | ||
/// </value> | ||
public bool BoolTest | ||
{ | ||
get => GetOrCreate(true); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the byte test. | ||
/// </summary> | ||
/// <value> | ||
/// The byte test. | ||
/// </value> | ||
public byte ByteTest | ||
{ | ||
get => GetOrCreate((byte)123); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the short test. | ||
/// </summary> | ||
/// <value> | ||
/// The short test. | ||
/// </value> | ||
public short ShortTest | ||
{ | ||
get => GetOrCreate((short)16); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the int test. | ||
/// </summary> | ||
/// <value> | ||
/// The int test. | ||
/// </value> | ||
public int IntTest | ||
{ | ||
get => GetOrCreate(1); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the long test. | ||
/// </summary> | ||
/// <value> | ||
/// The long test. | ||
/// </value> | ||
public long LongTest | ||
{ | ||
get => GetOrCreate(123456); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the string test. | ||
/// </summary> | ||
/// <value> | ||
/// The string test. | ||
/// </value> | ||
public string? StringTest | ||
{ | ||
get => GetOrCreate("TestString"); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the float test. | ||
/// </summary> | ||
/// <value> | ||
/// The float test. | ||
/// </value> | ||
public float FloatTest | ||
{ | ||
get => GetOrCreate(2.2f); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the double test. | ||
/// </summary> | ||
/// <value> | ||
/// The double test. | ||
/// </value> | ||
public double DoubleTest | ||
{ | ||
get => GetOrCreate(23.8d); set => SetOrCreate(value); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the enum test. | ||
/// </summary> | ||
/// <value> | ||
/// The enum test. | ||
/// </value> | ||
public EnumTestValue EnumTest | ||
{ | ||
get => GetOrCreate(EnumTestValue.Option1); set => SetOrCreate(value); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...eMarbles.CacheDatabase.Settings.Tests/ReactiveMarbles.CacheDatabase.Settings.Tests.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,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<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> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="FluentAssertions" Version="6.7.0" /> | ||
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.0.0" /> | ||
<PackageReference Include="ReactiveUI.Testing" Version="18.2.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ReactiveMarbles.CacheDatabase.Settings\ReactiveMarbles.CacheDatabase.Settings.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
45 changes: 45 additions & 0 deletions
45
src/ReactiveMarbles.CacheDatabase.Settings.Tests/SettingsCacheTests.cs
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,45 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
namespace ReactiveMarbles.CacheDatabase.Settings.Tests | ||
{ | ||
/// <summary> | ||
/// Settings Cache Tests. | ||
/// </summary> | ||
public class SettingsCacheTests | ||
{ | ||
/// <summary> | ||
/// Test1s this instance. | ||
/// </summary> | ||
[Fact] | ||
public async void TestCreateAndInsert() | ||
{ | ||
await AppInfo.DeleteSettingsStore<ViewSettings>(); | ||
var viewSettings = await AppInfo.SetupSettingsStore<ViewSettings>(); | ||
|
||
Assert.NotNull(viewSettings); | ||
Assert.True(viewSettings!.BoolTest); | ||
Assert.Equal((short)16, viewSettings.ShortTest); | ||
Assert.Equal(1, viewSettings.IntTest); | ||
Assert.Equal(123456L, viewSettings.LongTest); | ||
Assert.Equal("TestString", viewSettings.StringTest); | ||
Assert.Equal(2.2f, viewSettings.FloatTest); | ||
Assert.Equal(23.8d, viewSettings.DoubleTest); | ||
Assert.Equal(EnumTestValue.Option1, viewSettings.EnumTest); | ||
await viewSettings.DisposeAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests the update and read. | ||
/// </summary> | ||
[Fact] | ||
public async void TestUpdateAndRead() | ||
{ | ||
var viewSettings = await AppInfo.SetupSettingsStore<ViewSettings>(); | ||
viewSettings!.EnumTest = EnumTestValue.Option2; | ||
Assert.Equal(EnumTestValue.Option2, viewSettings.EnumTest); | ||
await viewSettings.DisposeAsync(); | ||
} | ||
} | ||
} |
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,5 @@ | ||
// Copyright (c) 2019-2022 ReactiveUI Association Incorporated. All rights reserved. | ||
// ReactiveUI Association Incorporated licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for full license information. | ||
|
||
global using Xunit; |
Oops, something went wrong.