@@ -565,7 +565,12 @@ static PullRequestService CreatePullRequestService(Repository repo)
565565 var serviceProvider = Substitutes . ServiceProvider ;
566566 var gitService = serviceProvider . GetGitService ( ) ;
567567 gitService . GetRepository ( repoDir ) . Returns ( repo ) ;
568- var service = new PullRequestService ( Substitute . For < IGitClient > ( ) , gitService , serviceProvider . GetOperatingSystem ( ) , Substitute . For < IUsageTracker > ( ) ) ;
568+ var service = new PullRequestService (
569+ Substitute . For < IGitClient > ( ) ,
570+ gitService ,
571+ Substitute . For < IVSGitExt > ( ) ,
572+ serviceProvider . GetOperatingSystem ( ) ,
573+ Substitute . For < IUsageTracker > ( ) ) ;
569574 return service ;
570575 }
571576
@@ -668,7 +673,12 @@ public void CreatePullRequestAllArgsMandatory()
668673 {
669674 var serviceProvider = Substitutes . ServiceProvider ;
670675 var gitService = serviceProvider . GetGitService ( ) ;
671- var service = new PullRequestService ( Substitute . For < IGitClient > ( ) , serviceProvider . GetGitService ( ) , serviceProvider . GetOperatingSystem ( ) , Substitute . For < IUsageTracker > ( ) ) ;
676+ var service = new PullRequestService (
677+ Substitute . For < IGitClient > ( ) ,
678+ serviceProvider . GetGitService ( ) ,
679+ Substitute . For < IVSGitExt > ( ) ,
680+ serviceProvider . GetOperatingSystem ( ) ,
681+ Substitute . For < IUsageTracker > ( ) ) ;
672682
673683 IModelService ms = null ;
674684 ILocalRepositoryModel sourceRepo = null ;
@@ -710,11 +720,7 @@ public class TheCheckoutMethod
710720 public async Task ShouldCheckoutExistingBranch ( )
711721 {
712722 var gitClient = MockGitClient ( ) ;
713- var service = new PullRequestService (
714- gitClient ,
715- MockGitService ( ) ,
716- Substitute . For < IOperatingSystem > ( ) ,
717- Substitute . For < IUsageTracker > ( ) ) ;
723+ var service = CreateTarget ( gitClient , MockGitService ( ) ) ;
718724
719725 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
720726 var pr = Substitute . For < IPullRequestModel > ( ) ;
@@ -733,11 +739,7 @@ public async Task ShouldCheckoutExistingBranch()
733739 public async Task ShouldCheckoutLocalBranch ( )
734740 {
735741 var gitClient = MockGitClient ( ) ;
736- var service = new PullRequestService (
737- gitClient ,
738- MockGitService ( ) ,
739- Substitute . For < IOperatingSystem > ( ) ,
740- Substitute . For < IUsageTracker > ( ) ) ;
742+ var service = CreateTarget ( gitClient , MockGitService ( ) ) ;
741743
742744 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
743745 localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -760,11 +762,7 @@ public async Task ShouldCheckoutLocalBranch()
760762 public async Task ShouldCheckoutBranchFromFork ( )
761763 {
762764 var gitClient = MockGitClient ( ) ;
763- var service = new PullRequestService (
764- gitClient ,
765- MockGitService ( ) ,
766- Substitute . For < IOperatingSystem > ( ) ,
767- Substitute . For < IUsageTracker > ( ) ) ;
765+ var service = CreateTarget ( gitClient , MockGitService ( ) ) ;
768766
769767 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
770768 localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -791,11 +789,7 @@ public async Task ShouldUseUniquelyNamedRemoteForFork()
791789 {
792790 var gitClient = MockGitClient ( ) ;
793791 var gitService = MockGitService ( ) ;
794- var service = new PullRequestService (
795- gitClient ,
796- gitService ,
797- Substitute . For < IOperatingSystem > ( ) ,
798- Substitute . For < IUsageTracker > ( ) ) ;
792+ var service = CreateTarget ( gitClient , gitService ) ;
799793
800794 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
801795 localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -825,11 +819,7 @@ public class TheGetDefaultLocalBranchNameMethod
825819 [ Test ]
826820 public async Task ShouldReturnCorrectDefaultLocalBranchName ( )
827821 {
828- var service = new PullRequestService (
829- MockGitClient ( ) ,
830- MockGitService ( ) ,
831- Substitute . For < IOperatingSystem > ( ) ,
832- Substitute . For < IUsageTracker > ( ) ) ;
822+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
833823
834824 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
835825 var result = await service . GetDefaultLocalBranchName ( localRepo , 123 , "Pull requests can be \" named\" all sorts of thing's (sic)" ) ;
@@ -842,6 +832,7 @@ public async Task ShouldReturnCorrectDefaultLocalBranchNameForPullRequestsWithNo
842832 var service = new PullRequestService (
843833 MockGitClient ( ) ,
844834 MockGitService ( ) ,
835+ Substitute . For < IVSGitExt > ( ) ,
845836 Substitute . For < IOperatingSystem > ( ) ,
846837 Substitute . For < IUsageTracker > ( ) ) ;
847838
@@ -853,11 +844,7 @@ public async Task ShouldReturnCorrectDefaultLocalBranchNameForPullRequestsWithNo
853844 [ Test ]
854845 public async Task DefaultLocalBranchNameShouldNotClashWithExistingBranchNames ( )
855846 {
856- var service = new PullRequestService (
857- MockGitClient ( ) ,
858- MockGitService ( ) ,
859- Substitute . For < IOperatingSystem > ( ) ,
860- Substitute . For < IUsageTracker > ( ) ) ;
847+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
861848
862849 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
863850 var result = await service . GetDefaultLocalBranchName ( localRepo , 123 , "foo1" ) ;
@@ -870,11 +857,7 @@ public class TheGetLocalBranchesMethod
870857 [ Test ]
871858 public async Task ShouldReturnPullRequestBranchForPullRequestFromSameRepository ( )
872859 {
873- var service = new PullRequestService (
874- MockGitClient ( ) ,
875- MockGitService ( ) ,
876- Substitute . For < IOperatingSystem > ( ) ,
877- Substitute . For < IUsageTracker > ( ) ) ;
860+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
878861
879862 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
880863 localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar" ) ) ;
@@ -905,11 +888,7 @@ public async Task ShouldReturnMarkedBranchForPullRequestFromFork()
905888
906889 repo . Config . Returns ( config ) ;
907890
908- var service = new PullRequestService (
909- MockGitClient ( ) ,
910- MockGitService ( repo ) ,
911- Substitute . For < IOperatingSystem > ( ) ,
912- Substitute . For < IUsageTracker > ( ) ) ;
891+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( repo ) ) ;
913892
914893 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
915894 localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar.git" ) ) ;
@@ -947,11 +926,7 @@ public async Task ShouldRemoveUnusedRemote()
947926 {
948927 var gitClient = MockGitClient ( ) ;
949928 var gitService = MockGitService ( ) ;
950- var service = new PullRequestService (
951- gitClient ,
952- gitService ,
953- Substitute . For < IOperatingSystem > ( ) ,
954- Substitute . For < IUsageTracker > ( ) ) ;
929+ var service = CreateTarget ( gitClient , gitService ) ;
955930
956931 var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
957932 localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar" ) ) ;
@@ -993,17 +968,20 @@ public async Task ShouldRemoveUnusedRemote()
993968 static PullRequestService CreateTarget (
994969 IGitClient gitClient = null ,
995970 IGitService gitService = null ,
971+ IVSGitExt gitExt = null ,
996972 IOperatingSystem os = null ,
997973 IUsageTracker usageTracker = null )
998974 {
999975 gitClient = gitClient ?? Substitute . For < IGitClient > ( ) ;
1000976 gitService = gitService ?? Substitute . For < IGitService > ( ) ;
977+ gitExt = gitExt ?? Substitute . For < IVSGitExt > ( ) ;
1001978 os = os ?? Substitute . For < IOperatingSystem > ( ) ;
1002979 usageTracker = usageTracker ?? Substitute . For < IUsageTracker > ( ) ;
1003980
1004981 return new PullRequestService (
1005982 gitClient ,
1006983 gitService ,
984+ gitExt ,
1007985 os ,
1008986 usageTracker ) ;
1009987 }
0 commit comments