@@ -565,7 +565,12 @@ static PullRequestService CreatePullRequestService(Repository repo)
565
565
var serviceProvider = Substitutes . ServiceProvider ;
566
566
var gitService = serviceProvider . GetGitService ( ) ;
567
567
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 > ( ) ) ;
569
574
return service ;
570
575
}
571
576
@@ -668,7 +673,12 @@ public void CreatePullRequestAllArgsMandatory()
668
673
{
669
674
var serviceProvider = Substitutes . ServiceProvider ;
670
675
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 > ( ) ) ;
672
682
673
683
IModelService ms = null ;
674
684
ILocalRepositoryModel sourceRepo = null ;
@@ -710,11 +720,7 @@ public class TheCheckoutMethod
710
720
public async Task ShouldCheckoutExistingBranch ( )
711
721
{
712
722
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 ( ) ) ;
718
724
719
725
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
720
726
var pr = Substitute . For < IPullRequestModel > ( ) ;
@@ -733,11 +739,7 @@ public async Task ShouldCheckoutExistingBranch()
733
739
public async Task ShouldCheckoutLocalBranch ( )
734
740
{
735
741
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 ( ) ) ;
741
743
742
744
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
743
745
localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -760,11 +762,7 @@ public async Task ShouldCheckoutLocalBranch()
760
762
public async Task ShouldCheckoutBranchFromFork ( )
761
763
{
762
764
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 ( ) ) ;
768
766
769
767
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
770
768
localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -791,11 +789,7 @@ public async Task ShouldUseUniquelyNamedRemoteForFork()
791
789
{
792
790
var gitClient = MockGitClient ( ) ;
793
791
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 ) ;
799
793
800
794
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
801
795
localRepo . CloneUrl . Returns ( new UriString ( "https://foo.bar/owner/repo" ) ) ;
@@ -825,11 +819,7 @@ public class TheGetDefaultLocalBranchNameMethod
825
819
[ Test ]
826
820
public async Task ShouldReturnCorrectDefaultLocalBranchName ( )
827
821
{
828
- var service = new PullRequestService (
829
- MockGitClient ( ) ,
830
- MockGitService ( ) ,
831
- Substitute . For < IOperatingSystem > ( ) ,
832
- Substitute . For < IUsageTracker > ( ) ) ;
822
+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
833
823
834
824
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
835
825
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
842
832
var service = new PullRequestService (
843
833
MockGitClient ( ) ,
844
834
MockGitService ( ) ,
835
+ Substitute . For < IVSGitExt > ( ) ,
845
836
Substitute . For < IOperatingSystem > ( ) ,
846
837
Substitute . For < IUsageTracker > ( ) ) ;
847
838
@@ -853,11 +844,7 @@ public async Task ShouldReturnCorrectDefaultLocalBranchNameForPullRequestsWithNo
853
844
[ Test ]
854
845
public async Task DefaultLocalBranchNameShouldNotClashWithExistingBranchNames ( )
855
846
{
856
- var service = new PullRequestService (
857
- MockGitClient ( ) ,
858
- MockGitService ( ) ,
859
- Substitute . For < IOperatingSystem > ( ) ,
860
- Substitute . For < IUsageTracker > ( ) ) ;
847
+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
861
848
862
849
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
863
850
var result = await service . GetDefaultLocalBranchName ( localRepo , 123 , "foo1" ) ;
@@ -870,11 +857,7 @@ public class TheGetLocalBranchesMethod
870
857
[ Test ]
871
858
public async Task ShouldReturnPullRequestBranchForPullRequestFromSameRepository ( )
872
859
{
873
- var service = new PullRequestService (
874
- MockGitClient ( ) ,
875
- MockGitService ( ) ,
876
- Substitute . For < IOperatingSystem > ( ) ,
877
- Substitute . For < IUsageTracker > ( ) ) ;
860
+ var service = CreateTarget ( MockGitClient ( ) , MockGitService ( ) ) ;
878
861
879
862
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
880
863
localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar" ) ) ;
@@ -905,11 +888,7 @@ public async Task ShouldReturnMarkedBranchForPullRequestFromFork()
905
888
906
889
repo . Config . Returns ( config ) ;
907
890
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 ) ) ;
913
892
914
893
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
915
894
localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar.git" ) ) ;
@@ -947,11 +926,7 @@ public async Task ShouldRemoveUnusedRemote()
947
926
{
948
927
var gitClient = MockGitClient ( ) ;
949
928
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 ) ;
955
930
956
931
var localRepo = Substitute . For < ILocalRepositoryModel > ( ) ;
957
932
localRepo . CloneUrl . Returns ( new UriString ( "https://github.com/foo/bar" ) ) ;
@@ -993,17 +968,20 @@ public async Task ShouldRemoveUnusedRemote()
993
968
static PullRequestService CreateTarget (
994
969
IGitClient gitClient = null ,
995
970
IGitService gitService = null ,
971
+ IVSGitExt gitExt = null ,
996
972
IOperatingSystem os = null ,
997
973
IUsageTracker usageTracker = null )
998
974
{
999
975
gitClient = gitClient ?? Substitute . For < IGitClient > ( ) ;
1000
976
gitService = gitService ?? Substitute . For < IGitService > ( ) ;
977
+ gitExt = gitExt ?? Substitute . For < IVSGitExt > ( ) ;
1001
978
os = os ?? Substitute . For < IOperatingSystem > ( ) ;
1002
979
usageTracker = usageTracker ?? Substitute . For < IUsageTracker > ( ) ;
1003
980
1004
981
return new PullRequestService (
1005
982
gitClient ,
1006
983
gitService ,
984
+ gitExt ,
1007
985
os ,
1008
986
usageTracker ) ;
1009
987
}
0 commit comments