lightweight variant (#1)
Reviewed-on: #1 Co-authored-by: Aleksandr Neychev <alexnejchev73@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using CursorLang.Agent.Windows;
|
||||
using CursorLang.Core.Services;
|
||||
using CursorLang.Tests.Shared;
|
||||
|
||||
namespace CursorLang.Agent.Tests.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// The one thing the settings window says to the agent.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Both halves of it live apart — the message and the window class name in Core, the
|
||||
/// window that answers in the agent — and nothing but a matching pair makes it work.
|
||||
/// A renamed class or a renamed message would leave the agent showing yesterday's
|
||||
/// settings until it is restarted, and nothing else would complain.
|
||||
///
|
||||
/// The agent's own window is used rather than a stand-in: what is being checked is
|
||||
/// that the window the agent really creates is the one the message reaches.
|
||||
/// </remarks>
|
||||
public sealed class SettingsSignalTests
|
||||
{
|
||||
[Fact]
|
||||
public void The_signal_reaches_the_agents_window()
|
||||
{
|
||||
var delivered = 0;
|
||||
|
||||
using AgentWindow window = Pump.Run(() =>
|
||||
{
|
||||
var created = new AgentWindow();
|
||||
created.AddFilter((message, _, _) =>
|
||||
{
|
||||
if (message != SettingsSignal.Message)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
delivered++;
|
||||
return true;
|
||||
});
|
||||
|
||||
return created;
|
||||
});
|
||||
|
||||
Pump.Run(SettingsSignal.NotifyAgent);
|
||||
Pump.Drain();
|
||||
|
||||
Assert.Equal(1, delivered);
|
||||
}
|
||||
|
||||
// Nobody is listening, and that is a normal state of affairs: the settings window
|
||||
// works perfectly well with no agent behind it
|
||||
[Fact]
|
||||
public void Signalling_with_no_agent_running_passes_without_consequence()
|
||||
{
|
||||
Pump.Run(SettingsSignal.NotifyAgent);
|
||||
Pump.Drain();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user