Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions tests/LageBuch.AppLogic.Tests/MainWindowViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class MainWindowViewModelTests
// ConnectAsync has no accept-any fallback -- it needs a real ITrustStore to even attempt the TLS
// handshake it's cancelling. A fresh temp-backed JsonTrustStore per HomeViewModel keeps every
// test's TOFU state isolated from the others.
private static MainWindowViewModel New(IFileDialogService? dialogs = null)
private static MainWindowViewModel New(IFileDialogService? dialogs = null, ILastConnectionStore? lastConnection = null)
{
var trustStore = new JsonTrustStore(Path.Join(Path.GetTempPath(), $"trust-{Guid.NewGuid():N}.json"));
var home = new HomeViewModel(new FakeStore(), new MvFakeMasterData(), new FakeRecent(), new FakeDialogs(), new FixedClock(T0), new FakeTicker(), new FakeAlarmService(), new NoopIncidentHostController(), "1.0.0", trustStore: trustStore);
var home = new HomeViewModel(new FakeStore(), new MvFakeMasterData(), new FakeRecent(), new FakeDialogs(), new FixedClock(T0), new FakeTicker(), new FakeAlarmService(), new NoopIncidentHostController(), "1.0.0", trustStore: trustStore, lastConnection: lastConnection);
return new MainWindowViewModel(home, new MasterDataEditorViewModel(new MvFakeMasterData(), new FakeDialogs(), new NoFiles()), dialogs ?? new FakeDialogs(), "0.1.0");
}

Expand Down Expand Up @@ -151,6 +151,28 @@ public async Task CancelJoin_aborts_a_stuck_connection_attempt_without_closing_t
Assert.IsType<HomeViewModel>(vm.CurrentView);
}

[Fact]
public void Join_prompt_prefills_the_host_and_pin_of_the_last_connection()
{
var vm = New(lastConnection: new FakeLastConnectionStore { Saved = new LastConnection("elw-1", null, T0, "5393") });

vm.RequestJoinDeviceCommand.Execute(null);

Assert.Equal("elw-1", vm.PendingPrompt?.Host);
Assert.Equal("5393", vm.PendingPrompt?.Pin);
}

[Fact]
public void Join_prompt_starts_empty_without_a_last_connection()
{
var vm = New(lastConnection: new FakeLastConnectionStore());

vm.RequestJoinDeviceCommand.Execute(null);

Assert.Equal(string.Empty, vm.PendingPrompt?.Host);
Assert.Equal(string.Empty, vm.PendingPrompt?.Pin);
}

[Fact]
public void RequestOpenFile_opens_readonly_without_prompt()
{
Expand Down
Loading