@@ -14,46 +14,29 @@ public class GitClientTests
1414 public class TheIsHeadPushedMethod : TestBaseClass
1515 {
1616 [ Theory ]
17- [ InlineData ( true , "sha" , "sha" , true ) ]
18- [ InlineData ( true , "xxx" , "yyy" , false ) ]
19- [ InlineData ( true , "headSha" , null , false ) ]
20- [ InlineData ( false , "sha" , "sha" , false ) ]
21- public async Task IsHeadPushed ( bool istracking , string headSha , string trackedBranchSha , bool expectHeadPushed )
17+ [ InlineData ( 0 , true ) ]
18+ [ InlineData ( 2 , false ) ]
19+ [ InlineData ( null , false ) ]
20+ public async Task IsHeadPushed ( int ? aheadBy , bool expected )
2221 {
2322 var gitClient = new GitClient ( Substitute . For < IGitHubCredentialProvider > ( ) ) ;
24- var repository = MockTrackedBranchRepository ( istracking , headSha , trackedBranchSha ) ;
23+ var repository = MockTrackedBranchRepository ( aheadBy ) ;
2524
2625 var isHeadPushed = await gitClient . IsHeadPushed ( repository ) ;
2726
28- Assert . Equal ( expectHeadPushed , isHeadPushed ) ;
27+ Assert . Equal ( expected , isHeadPushed ) ;
2928 }
3029
31- static IRepository MockTrackedBranchRepository ( bool isTracking , string headSha , string trackedBranchSha )
30+ static IRepository MockTrackedBranchRepository ( int ? aheadBy )
3231 {
33- var trackedBranch = Substitute . For < Branch > ( ) ;
34- var trackedBranchTip = MockCommitOrNull ( trackedBranchSha ) ;
35- trackedBranch . Tip . Returns ( trackedBranchTip ) ;
3632 var headBranch = Substitute . For < Branch > ( ) ;
37- var headTip = MockCommitOrNull ( headSha ) ;
38- headBranch . Tip . Returns ( headTip ) ;
39- headBranch . IsTracking . Returns ( isTracking ) ;
40- headBranch . TrackedBranch . Returns ( trackedBranch ) ;
33+ var trackingDetails = Substitute . For < BranchTrackingDetails > ( ) ;
34+ trackingDetails . AheadBy . Returns ( aheadBy ) ;
35+ headBranch . TrackingDetails . Returns ( trackingDetails ) ;
4136 var repository = Substitute . For < IRepository > ( ) ;
4237 repository . Head . Returns ( headBranch ) ;
4338 return repository ;
4439 }
45-
46- static Commit MockCommitOrNull ( string sha )
47- {
48- if ( sha != null )
49- {
50- var commit = Substitute . For < Commit > ( ) ;
51- commit . Sha . Returns ( sha ) ;
52- return commit ;
53- }
54-
55- return null ;
56- }
5740 }
5841
5942 public class ThePushMethod : TestBaseClass
0 commit comments