Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 442c51e

Browse files
committed
Fix tests
1 parent 9553e0e commit 442c51e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/UnitTests/GitHub.App/ViewModels/RepositoryPublishViewModelTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ public async Task DisplaysSuccessMessageWhenCompletedWithoutError()
339339

340340
vm.RepositoryName = "repo-name";
341341

342+
var obs = Substitute.For<IObserver<Exception>>();
343+
vm.PublishRepository.ThrownExceptions.Subscribe(obs);
342344
await vm.PublishRepository.ExecuteAsync().Catch(Observable.Return(Unit.Default));
343-
344-
vsServices.Received().ShowMessage("Repository published successfully.");
345-
vsServices.DidNotReceive().ShowError(Args.String);
345+
obs.DidNotReceiveWithAnyArgs().OnNext(null);
346346
}
347347

348348
[Fact]
@@ -358,10 +358,11 @@ public async Task DisplaysRepositoryExistsErrorWithVisualStudioNotifications()
358358
var vm = Helpers.SetupConnectionsAndViewModel(hosts, repositoryPublishService, vsServices, cm);
359359
vm.RepositoryName = "repo-name";
360360

361+
var obs = Substitute.For<IObserver<Exception>>();
362+
vm.PublishRepository.ThrownExceptions.Subscribe(obs);
361363
await vm.PublishRepository.ExecuteAsync().Catch(Observable.Return(Unit.Default));
362-
363-
vsServices.DidNotReceive().ShowMessage(Args.String);
364-
vsServices.Received().ShowError("There is already a repository named 'repo-name' for the current account.");
364+
obs.ReceivedWithAnyArgs().OnNext(null);
365+
Assert.True(obs.ReceivedCalls().Any(x => ((UnhandledUserErrorException)x.GetArguments()[0]).Message == "There is already a repository named 'repo-name' for the current account."));
365366
}
366367

367368
[Fact]
@@ -391,6 +392,7 @@ public async Task ClearsErrorsWhenSwitchingHosts()
391392

392393
vm.RepositoryName = "repo-name";
393394

395+
vm.PublishRepository.ThrownExceptions.Subscribe();
394396
await vm.PublishRepository.ExecuteAsync().Catch(Observable.Return(Unit.Default));
395397

396398
vm.SelectedConnection = conns.First(x => x != vm.SelectedConnection);
@@ -422,6 +424,7 @@ public async Task ClearsErrorsWhenSwitchingAccounts()
422424

423425
vm.RepositoryName = "repo-name";
424426

427+
vm.PublishRepository.ThrownExceptions.Subscribe();
425428
await vm.PublishRepository.ExecuteAsync().Catch(Observable.Return(Unit.Default));
426429

427430
vm.SelectedAccount = accounts[1];

0 commit comments

Comments
 (0)