@@ -506,19 +506,53 @@ public async Task ShouldDetectChangesToRemotes()
506
506
507
507
var repositoryManagerListener = Substitute . For < IRepositoryManagerListener > ( ) ;
508
508
repositoryManagerListener . AttachListener ( RepositoryManager , repositoryManagerEvents ) ;
509
-
509
+
510
+ RepositoryManager . WaitForEvents ( ) ;
511
+ repositoryManagerEvents . WaitForNotBusy ( 2 ) ;
512
+
513
+ repositoryManagerListener . AssertDidNotReceiveAnyCalls ( ) ;
514
+
515
+ Repository . Name . Should ( ) . Be ( "IOTestsRepo" ) ;
516
+ Repository . CloneUrl . ToString ( ) . Should ( ) . Be ( "https://github.com/EvilStanleyGoldman/IOTestsRepo.git" ) ;
517
+ Repository . Owner . Should ( ) . Be ( "EvilStanleyGoldman" ) ;
518
+ Repository . LocalPath . Should ( ) . Be ( TestRepoMasterCleanSynchronized ) ;
519
+ Repository . IsGitHub . Should ( ) . BeTrue ( ) ;
520
+ Repository . CurrentBranchName . Should ( ) . Be ( "master" ) ;
521
+ Repository . CurrentBranch . HasValue . Should ( ) . BeTrue ( ) ;
522
+ Repository . CurrentBranch . Value . Name . Should ( ) . Be ( "master" ) ;
523
+ Repository . CurrentRemote . HasValue . Should ( ) . BeTrue ( ) ;
524
+ Repository . CurrentRemote . Value . Name . Should ( ) . Be ( "origin" ) ;
525
+ Repository . CurrentRemote . Value . Url . Should ( ) . Be ( "https://github.com/EvilStanleyGoldman/IOTestsRepo.git" ) ;
526
+ Repository . LocalBranches . Should ( ) . BeEquivalentTo ( new [ ] {
527
+ new GitBranch ( "master" , "origin/master" , true ) ,
528
+ new GitBranch ( "feature/document" , "origin/feature/document" , false ) ,
529
+ new GitBranch ( "feature/other-feature" , "origin/feature/other-feature" , false ) ,
530
+ } ) ;
531
+ Repository . Remotes . Should ( ) . BeEquivalentTo ( new GitRemote
532
+ {
533
+ Name = "origin" ,
534
+ Url = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git"
535
+ } ) ;
536
+ Repository . RemoteBranches . Should ( ) . BeEquivalentTo ( new [ ] {
537
+ new GitBranch ( "origin/master" , "[None]" , false ) ,
538
+ new GitBranch ( "origin/feature/document-2" , "[None]" , false ) ,
539
+ new GitBranch ( "origin/feature/other-feature" , "[None]" , false ) ,
540
+ } ) ;
541
+
510
542
await RepositoryManager . RemoteRemove ( "origin" ) . StartAsAsync ( ) ;
511
543
await TaskManager . Wait ( ) ;
544
+
512
545
RepositoryManager . WaitForEvents ( ) ;
513
546
repositoryManagerEvents . WaitForNotBusy ( ) ;
547
+
514
548
repositoryManagerEvents . OnRemoteBranchListUpdated . WaitOne ( TimeSpan . FromSeconds ( 1 ) ) ;
515
549
repositoryManagerEvents . OnLocalBranchListUpdated . WaitOne ( TimeSpan . FromSeconds ( 1 ) ) ;
516
550
517
551
repositoryManagerListener . Received ( ) . OnIsBusyChanged ( Args . Bool ) ;
518
552
repositoryManagerListener . DidNotReceive ( ) . OnStatusUpdated ( Args . GitStatus ) ;
519
553
repositoryManagerListener . DidNotReceive ( ) . OnLocksUpdated ( Args . EnumerableGitLock ) ;
520
- repositoryManagerListener . DidNotReceive ( ) . OnCurrentBranchUpdated ( Arg . Any < ConfigBranch ? > ( ) ) ;
521
- repositoryManagerListener . DidNotReceive ( ) . OnCurrentRemoteUpdated ( Arg . Any < ConfigRemote ? > ( ) ) ;
554
+ repositoryManagerListener . Received ( ) . OnCurrentBranchUpdated ( Arg . Any < ConfigBranch ? > ( ) ) ;
555
+ repositoryManagerListener . Received ( ) . OnCurrentRemoteUpdated ( Arg . Any < ConfigRemote ? > ( ) ) ;
522
556
repositoryManagerListener . Received ( ) . OnLocalBranchListUpdated ( Arg . Any < Dictionary < string , ConfigBranch > > ( ) ) ;
523
557
repositoryManagerListener . Received ( ) . OnRemoteBranchListUpdated ( Arg . Any < Dictionary < string , ConfigRemote > > ( ) , Arg . Any < Dictionary < string , Dictionary < string , ConfigBranch > > > ( ) ) ;
524
558
repositoryManagerListener . DidNotReceive ( ) . OnLocalBranchUpdated ( Args . String ) ;
@@ -527,85 +561,78 @@ public async Task ShouldDetectChangesToRemotes()
527
561
repositoryManagerListener . DidNotReceive ( ) . OnRemoteBranchAdded ( Args . String , Args . String ) ;
528
562
repositoryManagerListener . Received ( ) . OnRemoteBranchRemoved ( Args . String , Args . String ) ;
529
563
564
+ Repository . Name . Should ( ) . Be ( "IOTestsRepo_master_clean_sync" ) ;
565
+ Repository . CloneUrl . Should ( ) . BeNull ( ) ;
566
+ Repository . Owner . Should ( ) . BeNull ( ) ;
567
+ Repository . LocalPath . Should ( ) . Be ( TestRepoMasterCleanSynchronized ) ;
568
+ Repository . IsGitHub . Should ( ) . BeFalse ( ) ;
569
+ Repository . CurrentBranchName . Should ( ) . Be ( "master" ) ;
570
+ Repository . CurrentBranch . HasValue . Should ( ) . BeTrue ( ) ;
571
+ Repository . CurrentBranch . Value . Name . Should ( ) . Be ( "master" ) ;
572
+ Repository . CurrentRemote . HasValue . Should ( ) . BeFalse ( ) ;
573
+ Repository . Remotes . Should ( ) . BeEquivalentTo ( ) ;
574
+ Repository . RemoteBranches . Should ( ) . BeEmpty ( ) ;
575
+
576
+ repositoryManagerListener . ClearReceivedCalls ( ) ;
577
+ repositoryManagerEvents . Reset ( ) ;
578
+
579
+ await RepositoryManager . RemoteAdd ( "origin" , "https://github.com/EvilShana/IOTestsRepo.git" ) . StartAsAsync ( ) ;
580
+ await TaskManager . Wait ( ) ;
581
+ RepositoryManager . WaitForEvents ( ) ;
582
+ repositoryManagerEvents . WaitForNotBusy ( ) ;
583
+ repositoryManagerEvents . OnRemoteBranchListUpdated . WaitOne ( TimeSpan . FromSeconds ( 1 ) ) ;
584
+ repositoryManagerEvents . OnLocalBranchListUpdated . WaitOne ( TimeSpan . FromSeconds ( 1 ) ) ;
585
+
586
+ repositoryManagerListener . Received ( ) . OnIsBusyChanged ( Args . Bool ) ;
587
+ repositoryManagerListener . DidNotReceive ( ) . OnStatusUpdated ( Args . GitStatus ) ;
588
+ repositoryManagerListener . DidNotReceive ( ) . OnLocksUpdated ( Args . EnumerableGitLock ) ;
589
+ repositoryManagerListener . Received ( ) . OnCurrentBranchUpdated ( Arg . Any < ConfigBranch ? > ( ) ) ;
590
+ repositoryManagerListener . Received ( ) . OnCurrentRemoteUpdated ( Arg . Any < ConfigRemote ? > ( ) ) ;
591
+ repositoryManagerListener . Received ( ) . OnLocalBranchListUpdated ( Arg . Any < Dictionary < string , ConfigBranch > > ( ) ) ;
592
+ repositoryManagerListener . Received ( ) . OnRemoteBranchListUpdated ( Arg . Any < Dictionary < string , ConfigRemote > > ( ) , Arg . Any < Dictionary < string , Dictionary < string , ConfigBranch > > > ( ) ) ;
593
+ repositoryManagerListener . DidNotReceive ( ) . OnLocalBranchUpdated ( Args . String ) ;
594
+ repositoryManagerListener . DidNotReceive ( ) . OnLocalBranchAdded ( Args . String ) ;
595
+ repositoryManagerListener . DidNotReceive ( ) . OnLocalBranchRemoved ( Args . String ) ;
596
+ repositoryManagerListener . DidNotReceive ( ) . OnRemoteBranchAdded ( Args . String , Args . String ) ;
597
+ repositoryManagerListener . DidNotReceive ( ) . OnRemoteBranchRemoved ( Args . String , Args . String ) ;
598
+
530
599
Repository . Name . Should ( ) . Be ( "IOTestsRepo" ) ;
531
- Repository . CloneUrl . ToString ( ) . Should ( ) . Be ( "https://github.com/EvilStanleyGoldman /IOTestsRepo.git" ) ;
532
- Repository . Owner . Should ( ) . Be ( "EvilStanleyGoldman " ) ;
600
+ Repository . CloneUrl . ToString ( ) . Should ( ) . Be ( "https://github.com/EvilShana /IOTestsRepo.git" ) ;
601
+ Repository . Owner . Should ( ) . Be ( "EvilShana " ) ;
533
602
Repository . LocalPath . Should ( ) . Be ( TestRepoMasterCleanSynchronized ) ;
534
603
Repository . IsGitHub . Should ( ) . BeTrue ( ) ;
535
604
Repository . CurrentBranchName . Should ( ) . Be ( "master" ) ;
536
605
Repository . CurrentBranch . HasValue . Should ( ) . BeTrue ( ) ;
537
606
Repository . CurrentBranch . Value . Name . Should ( ) . Be ( "master" ) ;
538
607
Repository . CurrentRemote . HasValue . Should ( ) . BeTrue ( ) ;
539
608
Repository . CurrentRemote . Value . Name . Should ( ) . Be ( "origin" ) ;
540
- Repository . CurrentRemote . Value . Url . Should ( ) . Be ( "https://github.com/EvilStanleyGoldman /IOTestsRepo.git" ) ;
609
+ Repository . CurrentRemote . Value . Url . Should ( ) . Be ( "https://github.com/EvilShana /IOTestsRepo.git" ) ;
541
610
Repository . LocalBranches . Should ( ) . BeEquivalentTo ( new [ ] {
542
611
new GitBranch ( "master" , "[None]" , true ) ,
543
612
new GitBranch ( "feature/document" , "[None]" , false ) ,
544
613
new GitBranch ( "feature/other-feature" , "[None]" , false ) ,
545
614
} ) ;
546
- Repository . Remotes . Should ( ) . BeEquivalentTo ( ) ;
615
+ Repository . Remotes . Should ( ) . BeEquivalentTo ( new GitRemote
616
+ {
617
+ Name = "origin" ,
618
+ Url = "https://github.com/EvilShana/IOTestsRepo.git"
619
+ } ) ;
547
620
Repository . RemoteBranches . Should ( ) . BeEmpty ( ) ;
548
-
549
- repositoryManagerListener . ClearReceivedCalls ( ) ;
550
- repositoryManagerEvents . Reset ( ) ;
551
-
552
- // await RepositoryManager.RemoteAdd("origin", "https://github.com/EvilShana/IOTestsRepo.git").StartAsAsync();
553
- // await TaskManager.Wait();
554
- // RepositoryManager.WaitForEvents();
555
- // repositoryManagerEvents.WaitForNotBusy();
556
- // repositoryManagerEvents.OnRemoteBranchListUpdated.WaitOne(TimeSpan.FromSeconds(1));
557
- // repositoryManagerEvents.OnLocalBranchListUpdated.WaitOne(TimeSpan.FromSeconds(1));
558
- //
559
- // repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool);
560
- // repositoryManagerListener.DidNotReceive().OnStatusUpdated(Args.GitStatus);
561
- // repositoryManagerListener.DidNotReceive().OnLocksUpdated(Args.EnumerableGitLock);
562
- // repositoryManagerListener.DidNotReceive().OnCurrentBranchUpdated(Arg.Any<ConfigBranch?>());
563
- // repositoryManagerListener.DidNotReceive().OnCurrentRemoteUpdated(Arg.Any<ConfigRemote?>());
564
- // repositoryManagerListener.Received().OnLocalBranchListUpdated(Arg.Any<Dictionary<string, ConfigBranch>>());
565
- // repositoryManagerListener.Received().OnRemoteBranchListUpdated(Arg.Any<Dictionary<string, ConfigRemote>>(), Arg.Any<Dictionary<string, Dictionary<string, ConfigBranch>>>());
566
- // repositoryManagerListener.DidNotReceive().OnLocalBranchUpdated(Args.String);
567
- // repositoryManagerListener.DidNotReceive().OnLocalBranchAdded(Args.String);
568
- // repositoryManagerListener.DidNotReceive().OnLocalBranchRemoved(Args.String);
569
- // repositoryManagerListener.DidNotReceive().OnRemoteBranchAdded(Args.String, Args.String);
570
- // repositoryManagerListener.DidNotReceive().OnRemoteBranchRemoved(Args.String, Args.String);
571
- //
572
- // Repository.Name.Should().Be("IOTestsRepo");
573
- // Repository.CloneUrl.ToString().Should().Be("https://github.com/EvilStanleyGoldman/IOTestsRepo.git");
574
- // Repository.Owner.Should().Be("EvilStanleyGoldman");
575
- // Repository.LocalPath.Should().Be(TestRepoMasterCleanSynchronized);
576
- // Repository.IsGitHub.Should().BeTrue();
577
- // Repository.CurrentBranchName.Should().Be("master");
578
- // Repository.CurrentBranch.HasValue.Should().BeTrue();
579
- // Repository.CurrentBranch.Value.Name.Should().Be("master");
580
- // Repository.CurrentBranch.Value.Remote.HasValue.Should().BeTrue();
581
- // Repository.CurrentBranch.Value.Remote.Value.Name.Should().Be("origin");
582
- // Repository.CurrentBranch.Value.Remote.Value.Url.Should().Be("https://github.com/EvilStanleyGoldman/IOTestsRepo.git");
583
- // Repository.CurrentRemote.HasValue.Should().BeTrue();
584
- // Repository.CurrentRemote.Value.Name.Should().Be("origin");
585
- // Repository.CurrentRemote.Value.Url.Should().Be("https://github.com/EvilStanleyGoldman/IOTestsRepo.git");
586
- // Repository.LocalBranches.Should().BeEquivalentTo(new[] {
587
- // new GitBranch("master", "[None]", true),
588
- // new GitBranch("feature/document", "[None]", false),
589
- // new GitBranch("feature/other-feature", "[None]", false),
590
- // });
591
- // Repository.Remotes.Should().BeEquivalentTo(new GitRemote
592
- // {
593
- // Name = "origin",
594
- // Url = "https://github.com/EvilShana/IOTestsRepo.git"
595
- // });
596
- // Repository.RemoteBranches.Should().BeEmpty();
597
621
}
598
622
599
623
[ Test ]
600
624
public async Task ShouldDetectChangesToRemotesWhenSwitchingBranches ( )
601
625
{
602
- var expectedCloneUrl = "https://github.com/EvilStanleyGoldman/IOTestsRepo.git" ;
603
-
604
626
await Initialize ( TestRepoMasterTwoRemotes ) ;
605
627
606
628
var repositoryManagerListener = Substitute . For < IRepositoryManagerListener > ( ) ;
607
629
repositoryManagerListener . AttachListener ( RepositoryManager , repositoryManagerEvents ) ;
608
630
631
+ RepositoryManager . WaitForEvents ( ) ;
632
+ repositoryManagerEvents . WaitForNotBusy ( 2 ) ;
633
+
634
+ repositoryManagerListener . AssertDidNotReceiveAnyCalls ( ) ;
635
+
609
636
Repository . Name . Should ( ) . Be ( "IOTestsRepo" ) ;
610
637
Repository . CloneUrl . ToString ( ) . Should ( ) . Be ( "https://github.com/EvilStanleyGoldman/IOTestsRepo.git" ) ;
611
638
Repository . Owner . Should ( ) . Be ( "EvilStanleyGoldman" ) ;
@@ -650,8 +677,8 @@ await RepositoryManager.CreateBranch("branch2", "another/master")
650
677
repositoryManagerListener . Received ( ) . OnIsBusyChanged ( Args . Bool ) ;
651
678
repositoryManagerListener . DidNotReceive ( ) . OnStatusUpdated ( Args . GitStatus ) ;
652
679
repositoryManagerListener . DidNotReceive ( ) . OnLocksUpdated ( Args . EnumerableGitLock ) ;
653
- repositoryManagerListener . DidNotReceive ( ) . OnCurrentBranchUpdated ( Arg . Any < ConfigBranch ? > ( ) ) ;
654
- repositoryManagerListener . DidNotReceive ( ) . OnCurrentRemoteUpdated ( Arg . Any < ConfigRemote ? > ( ) ) ;
680
+ repositoryManagerListener . Received ( ) . OnCurrentBranchUpdated ( Arg . Any < ConfigBranch ? > ( ) ) ;
681
+ repositoryManagerListener . Received ( ) . OnCurrentRemoteUpdated ( Arg . Any < ConfigRemote ? > ( ) ) ;
655
682
repositoryManagerListener . Received ( ) . OnLocalBranchListUpdated ( Arg . Any < Dictionary < string , ConfigBranch > > ( ) ) ;
656
683
repositoryManagerListener . Received ( ) . OnRemoteBranchListUpdated ( Arg . Any < Dictionary < string , ConfigRemote > > ( ) , Arg . Any < Dictionary < string , Dictionary < string , ConfigBranch > > > ( ) ) ;
657
684
repositoryManagerListener . DidNotReceive ( ) . OnLocalBranchUpdated ( Args . String ) ;
0 commit comments