mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-09-24 10:53:37 +00:00
Some checks are pending
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using AIStudio.Tools.Services;
|
|
|
|
namespace AIStudio.Tests.Tools;
|
|
|
|
/// <summary>
|
|
/// Checks when the circuit state reports that the browser connection came back.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The report is there to fetch again what the browser sent while the connection was down, because Blazor
|
|
/// drops it. The layout reads the color theme anew on it, for instance, since the machine may have switched
|
|
/// its theme during sleep. So it has to come after every loss, and only then: missing one leaves the app
|
|
/// with stale state, while a connection which was never lost has nothing to fetch again.
|
|
/// </remarks>
|
|
[TestFixture]
|
|
public sealed class CircuitStateServiceTests
|
|
{
|
|
[Test]
|
|
public void AConnectionWhichReturnsAfterALossIsReportedOnce()
|
|
{
|
|
var circuitState = new CircuitStateService();
|
|
var numReports = 0;
|
|
circuitState.ConnectionRestored += () => numReports++;
|
|
|
|
circuitState.MarkAsDisconnected();
|
|
circuitState.MarkAsConnected();
|
|
|
|
Assert.That(numReports, Is.EqualTo(1), "The connection was lost and came back, so whatever the browser sent in between is gone.");
|
|
Assert.That(circuitState.IsConnected, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public void TheFirstConnectionIsNotReported()
|
|
{
|
|
var circuitState = new CircuitStateService();
|
|
var numReports = 0;
|
|
circuitState.ConnectionRestored += () => numReports++;
|
|
|
|
circuitState.MarkAsConnected();
|
|
|
|
Assert.That(numReports, Is.Zero, "A circuit starts out connected, so its first connection has not lost anything.");
|
|
}
|
|
|
|
[Test]
|
|
public void AConnectionWhichWasNotLostIsNotReportedAgain()
|
|
{
|
|
var circuitState = new CircuitStateService();
|
|
var numReports = 0;
|
|
circuitState.ConnectionRestored += () => numReports++;
|
|
|
|
circuitState.MarkAsDisconnected();
|
|
circuitState.MarkAsConnected();
|
|
circuitState.MarkAsConnected();
|
|
|
|
Assert.That(numReports, Is.EqualTo(1), "The second call follows a connection which was up all along.");
|
|
}
|
|
|
|
[Test]
|
|
public void EveryLossIsReportedOnItsOwn()
|
|
{
|
|
var circuitState = new CircuitStateService();
|
|
var numReports = 0;
|
|
circuitState.ConnectionRestored += () => numReports++;
|
|
|
|
circuitState.MarkAsDisconnected();
|
|
circuitState.MarkAsConnected();
|
|
circuitState.MarkAsDisconnected();
|
|
circuitState.MarkAsConnected();
|
|
|
|
Assert.That(numReports, Is.EqualTo(2), "The machine went to sleep twice, and each time something may have been lost.");
|
|
}
|
|
} |