-
Notifications
You must be signed in to change notification settings - Fork 58
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 #382 from TimeWarpEngineering/Cramer/2024-02-22/Tests
Cramer/2024 02 22/tests
- Loading branch information
Showing
27 changed files
with
215 additions
and
169 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
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
14 changes: 7 additions & 7 deletions
14
...tateActionsHandlers/Sample/Client/Features/Counter/Actions/CounterState.IncrementCount.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
16 changes: 7 additions & 9 deletions
16
Samples/01-StateActionsHandlers/Sample/Client/Features/Counter/CounterState.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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
namespace Sample.Client.Features.Counter; | ||
|
||
using BlazorState; | ||
|
||
public partial class CounterState : State<CounterState> | ||
{ | ||
public int Count { get; private set; } | ||
public override void Initialize() => Count = 3; | ||
} | ||
namespace Sample.Client.Features.Counter; | ||
|
||
public partial class CounterState : State<CounterState> | ||
{ | ||
public int Count { get; private set; } | ||
public override void Initialize() => Count = 3; | ||
} |
2 changes: 2 additions & 0 deletions
2
Samples/01-StateActionsHandlers/Sample/Client/GlobalUsings.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,2 @@ | ||
global using BlazorState; | ||
global using JetBrains.Annotations; |
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 |
---|---|---|
@@ -1,26 +1,25 @@ | ||
using BlazorState; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Sample.Client; | ||
using System.Reflection; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("head::after"); | ||
|
||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | ||
|
||
builder.Services.AddBlazorState | ||
( | ||
options => | ||
{ | ||
options.UseReduxDevTools(); | ||
options.Assemblies = | ||
new Assembly[] | ||
{ | ||
typeof(Program).GetTypeInfo().Assembly, | ||
}; | ||
} | ||
); | ||
|
||
await builder.Build().RunAsync(); | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Sample.Client; | ||
using System.Reflection; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.Add<App>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("head::after"); | ||
|
||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); | ||
|
||
builder.Services.AddBlazorState | ||
( | ||
options => | ||
{ | ||
options.UseReduxDevTools(); | ||
options.Assemblies = | ||
new Assembly[] | ||
{ | ||
typeof(Program).GetTypeInfo().Assembly, | ||
}; | ||
} | ||
); | ||
|
||
await builder.Build().RunAsync(); |
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
This file was deleted.
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
2 changes: 1 addition & 1 deletion
2
Tests/Test.App/Test.App.Client/Features/CloneTest/Actions/IncrementCount/CloneTestAction.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Test.App.Client.Features.CloneTest; | ||
|
||
internal partial class CloneTestState | ||
internal partial class CloneableState | ||
{ | ||
internal class CloneTestAction : IAction; | ||
} |
15 changes: 12 additions & 3 deletions
15
Tests/Test.App/Test.App.Client/Features/CloneTest/Actions/IncrementCount/CloneTestHandler.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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
namespace Test.App.Client.Features.CloneTest; | ||
|
||
[UsedImplicitly] | ||
internal partial class CloneTestState | ||
internal partial class CloneableState | ||
{ | ||
[UsedImplicitly] | ||
internal class CloneTestHandler | ||
( | ||
IStore store | ||
) : BaseActionHandler<CloneTestAction>(store) | ||
{ | ||
public override Task<Unit> Handle | ||
private CloneableState CloneableState => Store.GetState<CloneableState>(); | ||
|
||
public override Task Handle | ||
( | ||
CloneTestAction aCloneTestAction, | ||
CancellationToken aCancellationToken | ||
) => Unit.Task; | ||
) | ||
{ | ||
// Note: This is a test to verify that the state is cloned. | ||
// It is not an example of any real-world usage. | ||
if ( CloneableState.Count != 42) throw new Exception("Count is not 42 it seems I have failed to clone the state"); | ||
CloneableState.Count++; | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
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
12 changes: 0 additions & 12 deletions
12
Tests/Test.App/Test.App.Client/Features/CloneTest/CloneTestState.cs
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
Tests/Test.App/Test.App.Client/Features/CloneTest/CloneableState.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,18 @@ | ||
namespace Test.App.Client.Features.CloneTest; | ||
|
||
internal partial class CloneableState : State<CloneableState>, ICloneable | ||
{ | ||
public int Count { get; private set; } | ||
|
||
/// <summary> | ||
/// Set the Initial State | ||
/// </summary> | ||
public override void Initialize() => Count = 3; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <remarks>We are trying to prove ICloneable is used when available instead of AnyClone.</remarks> | ||
/// <returns>New CloneableState object where Count is always 42</returns> | ||
public object Clone() => new CloneableState { Count = 42 }; | ||
} |
Oops, something went wrong.