Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenTCramer committed Aug 3, 2024
1 parent 23dd6c9 commit 27a8975
Show file tree
Hide file tree
Showing 27 changed files with 45 additions and 32 deletions.
8 changes: 8 additions & 0 deletions Tests/Test.App.Architecture.Tests/ArchitectureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ public static void FollowActionHandlerPolicy()
PolicyResults results = policy.Evaluate();
results.ShouldBeSuccessful();
}

public static void FollowStatePolicy()
{
Assembly sut = typeof(Test.App.Client.AssemblyMarker).Assembly;
PolicyDefinition policy = Policies.CreateStatePolicy(sut);
PolicyResults results = policy.Evaluate();
results.ShouldBeSuccessful();
}
}
3 changes: 2 additions & 1 deletion Tests/Test.App.EndToEnd.Tests/CacheableWeatherPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ private async Task ValidateWeatherForecastsAndCacheState(bool isCached, string?
await Expect(WeatherTableLocator).ToBeVisibleAsync();

// Validate the cache key
const string cacheKey = "Test.App.Client.Features.WeatherForecast.CacheableWeatherState+FetchWeatherForecasts+Action|{}";

const string cacheKey = "Test.App.Client.Features.WeatherForecast.CacheableWeatherState+FetchWeatherForecastsActionSet+Action|{}";
await Expect(CacheKeyLocator).ToHaveTextAsync(cacheKey);

// Validate the timestamp
Expand Down
4 changes: 2 additions & 2 deletions Tests/Test.App.EndToEnd.Tests/EventStreamPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private async Task ValidateEventStream(string expectedCurrentMode)
private async Task ValidateEventsList()
{
string eventsText = await EventsListLocator.TextContentAsync() ?? throw new InvalidOperationException("Events list text content is null.");
Assert.IsTrue(eventsText.Contains("Start:Test.App.Client.Features.Counter.CounterState+IncrementCount+Action"), "Start event not found.");
Assert.IsTrue(eventsText.Contains("Completed:Test.App.Client.Features.Counter.CounterState+IncrementCount+Action"), "Completed event not found.");
Assert.IsTrue(eventsText.Contains("Start:Test.App.Client.Features.Counter.CounterState+IncrementCountActionSet+Action"), "Start event not found.");
Assert.IsTrue(eventsText.Contains("Completed:Test.App.Client.Features.Counter.CounterState+IncrementCountActionSet+Action"), "Completed event not found.");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.Application;

public partial class ApplicationState : State<ApplicationState>
public sealed partial class ApplicationState : State<ApplicationState>
{
public string Name { get; private set; } = null!;
public string? ExceptionMessage { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion Tests/Test.App/Test.App.Client/Features/Blue/BlueState.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Test.App.Client.Features.Blue;

[PersistentState(PersistentStateMethod.SessionStorage)]
public partial class BlueState : State<BlueState>
public sealed partial class BlueState : State<BlueState>
{
public int Count { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Test.App.Client.Features.WeatherForecast;

using static Contracts.Features.WeatherForecast.GetWeatherForecasts;

internal sealed partial class CacheableWeatherState
public partial class CacheableWeatherState
{
public static class FetchWeatherForecastsActionSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace Test.App.Client.Features.WeatherForecast;

using TimeWarp.State.Plus.State;
using static Contracts.Features.WeatherForecast.GetWeatherForecasts;

internal partial class CacheableWeatherState: TimeWarpCacheableState<CacheableWeatherState>
public sealed partial class CacheableWeatherState: TimeWarpCacheableState<CacheableWeatherState>
{
private Response? WeatherForecastList;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.CloneTest;

internal partial class CloneableState
public partial class CloneableState
{
public static class CloneTestActionSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.CloneTest;

internal partial class CloneableState
public partial class CloneableState
{
public override CloneableState Hydrate(IDictionary<string, object> keyValuePairs)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.CloneTest;

internal partial class CloneableState : State<CloneableState>, ICloneable
public sealed partial class CloneableState : State<CloneableState>, ICloneable
{
public int Count { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Test.App.Client.Features.Counter;

using System.Drawing;

internal partial class ColorState
public partial class ColorState
{
public override ColorState Hydrate(IDictionary<string, object> keyValuePairs)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Test.App.Client.Features.Counter;
using System.Drawing;

[UsedImplicitly]
internal partial class ColorState : State<ColorState>
public sealed partial class ColorState : State<ColorState>
{
public string MyColorName { get; private set; } = null!;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.Counter;

public partial class CounterState : State<CounterState>
public sealed partial class CounterState : State<CounterState>
{

public int Count { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.EventStream;

internal partial class EventStreamState
public partial class EventStreamState
{
public static class AddEventActionSet
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.EventStream;

internal partial class EventStreamState
public partial class EventStreamState
{
[UsedImplicitly]
internal void Initialize(List<string> events)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Test.App.Client.Features.EventStream;

internal partial class EventStreamState : State<EventStreamState>
public sealed partial class EventStreamState : State<EventStreamState>
{
private List<string> EventList { get; set; } = [];
public IReadOnlyList<string> Events => EventList.AsReadOnly();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Test.App.Client.Features.Purple;

[PersistentState(PersistentStateMethod.LocalStorage)]
public partial class PurpleState : State<PurpleState>
public sealed partial class PurpleState : State<PurpleState>
{
public int Count { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Test.App.Client.Features.WeatherForecast;

using static Contracts.Features.WeatherForecast.GetWeatherForecasts;

internal sealed partial class WeatherForecastsState
public partial class WeatherForecastsState
{
public static class FetchWeatherForecastsActionSet
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Test.App.Client.Features.WeatherForecast;

using static Contracts.Features.WeatherForecast.GetWeatherForecasts;

internal partial class WeatherForecastsState: State<WeatherForecastsState>
public sealed partial class WeatherForecastsState: State<WeatherForecastsState>
{
private Response? WeatherForecastList;

Expand Down
3 changes: 3 additions & 0 deletions Tests/Test.App/Test.App.Client/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ReSharper disable once RedundantUsingDirective.Global
global using Microsoft.AspNetCore.Components;
global using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Logging;
global using Microsoft.JSInterop;
global using System;
Expand Down Expand Up @@ -48,4 +49,6 @@
global using TimeWarp.Features.StateTransactions;
global using TimeWarp.State.Plus;
global using TimeWarp.Features.Theme;
global using TimeWarp.State.Plus.Extensions;
global using TimeWarp.State.Plus.PersistentState;
global using TimeWarp.State.Plus.State;
4 changes: 1 addition & 3 deletions Tests/Test.App/Test.App.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
namespace Test.App.Client;

using TimeWarp.State.Plus.Extensions;
using Microsoft.Extensions.DependencyInjection;

public class Program
{
private static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging"));
SetIsoCulture();
ConfigureServices(builder.Services);

Expand Down
2 changes: 2 additions & 0 deletions Tests/Test.App/Test.App.Client/Test.App.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="timewarp-heroicons" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<!-- <PackageReference Include="TimeWarp.State" />-->
<!-- <PackageReference Include="TimeWarp.State.Plus" />-->
</ItemGroup>
Expand Down Expand Up @@ -43,4 +44,5 @@
<Compile Remove="$(GeneratedFolder)/**/*.cs" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { log, LogAction } from '/_content/TimeWarp.State/js/Logger.js'

const dispatchIncrementCountAction = () => {
log("dispatchIncrementCountAction", "Dispatching IncrementCountAction", "function");
const IncrementCountActionName = "Test.App.Client.Features.Counter.CounterState+IncrementCount+Action, Test.App.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
const IncrementCountActionName = "Test.App.Client.Features.Counter.CounterState+IncrementCountActionSet+Action, Test.App.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
timeWarpState.DispatchRequest(IncrementCountActionName, { amount: 7 });
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Default": "Trace",
"Microsoft.AspNetCore": "Warning"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Default": "Trace",
"Microsoft.AspNetCore": "Warning"
}
}
Expand Down
8 changes: 8 additions & 0 deletions Tests/TimeWarp.State.Plus.Tests/ArchitectureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ public static void FollowActionHandlerPolicy()
PolicyResults results = policy.Evaluate();
results.ShouldBeSuccessful();
}

public static void FollowStatePolicy()
{
Assembly sut = typeof(TimeWarp.State.Plus.AssemblyMarker).Assembly;
PolicyDefinition policy = Policies.CreateStatePolicy(sut);
PolicyResults results = policy.Evaluate();
results.ShouldBeSuccessful();
}
}
6 changes: 0 additions & 6 deletions Tests/TimeWarp.State.Plus.Tests/Class1.cs

This file was deleted.

0 comments on commit 27a8975

Please sign in to comment.