Skip to content

Commit 45fef53

Browse files
CopilotChrisPulman
andcommitted
Improve test assertions and patterns based on code review feedback
Agent-Logs-Url: https://github.com/reactiveui/ReactiveUI/sessions/5cabc9fc-ac07-4031-8321-2755aec01237 Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
1 parent 3e92c94 commit 45fef53

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/tests/ReactiveUI.WinForms.Tests/winforms/ReactiveCommandWinFormsOutputTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ public async Task ReactiveCommand_IsExecuting_TracksExecutionState()
122122

123123
using (Assert.Multiple())
124124
{
125-
// Should have at least: false (initial), true (executing), false (completed)
126-
await Assert.That(executingValues).Count().IsGreaterThanOrEqualTo(2);
125+
// Should have: false (initial), true (executing), false (completed)
126+
await Assert.That(executingValues).Count().IsGreaterThanOrEqualTo(3);
127127
await Assert.That(executingValues[0]).IsFalse();
128+
await Assert.That(executingValues[1]).IsTrue();
129+
await Assert.That(executingValues[executingValues.Count - 1]).IsFalse();
128130
}
129131
}
130132

@@ -163,7 +165,9 @@ public async Task InvokeCommand_ExecutesCommand_AndOutputPropagates()
163165
var results = new List<string>();
164166
command.Subscribe(x => results.Add(x));
165167

166-
Observable.Return("hello").InvokeCommand(command);
168+
var source = new Subject<string>();
169+
source.InvokeCommand(command);
170+
source.OnNext("hello");
167171

168172
await Assert.That(results).Count().IsEqualTo(1);
169173
await Assert.That(results[0]).IsEqualTo("HELLO");
@@ -183,7 +187,9 @@ public async Task InvokeCommand_WithTarget_ExecutesCommand_AndOutputPropagates()
183187
var results = new List<string>();
184188
viewModel.NavigateCommand.Subscribe(x => results.Add(x));
185189

186-
Observable.Return("page1").InvokeCommand(viewModel, vm => vm.NavigateCommand);
190+
var source = new Subject<string>();
191+
source.InvokeCommand(viewModel, vm => vm.NavigateCommand);
192+
source.OnNext("page1");
187193

188194
await Assert.That(results).Count().IsEqualTo(1);
189195
await Assert.That(results[0]).IsEqualTo("page1");

0 commit comments

Comments
 (0)