77using Xunit ;
88using GitHub . Primitives ;
99using Xunit . Abstractions ;
10+ using System . Collections . Generic ;
11+ using System . Threading . Tasks ;
1012
1113[ Collection ( "PackageServiceProvider global data tests" ) ]
1214public class LocalRepositoryModelTests : TestBaseClass
@@ -24,8 +26,13 @@ static void SetupRepository(string sha)
2426 var gitservice = provider . GetGitService ( ) ;
2527 var repo = Substitute . For < IRepository > ( ) ;
2628 gitservice . GetRepository ( Args . String ) . Returns ( repo ) ;
29+ gitservice . GetLatestPushedSha ( Args . String ) . Returns ( Task . FromResult ( sha ) ) ;
2730 if ( ! String . IsNullOrEmpty ( sha ) )
2831 {
32+ var refs = Substitute . For < ReferenceCollection > ( ) ;
33+ var refrence = Substitute . For < Reference > ( ) ;
34+ refs . ReachableFrom ( Arg . Any < IEnumerable < Reference > > ( ) , Arg . Any < IEnumerable < Commit > > ( ) ) . Returns ( new Reference [ ] { refrence } ) ;
35+ repo . Refs . Returns ( refs ) ;
2936 var commit = Substitute . For < Commit > ( ) ;
3037 commit . Sha . Returns ( sha ) ;
3138 repo . Commits . Returns ( new FakeCommitLog { commit } ) ;
@@ -54,7 +61,7 @@ static void SetupRepository(string sha)
5461 [ InlineData ( 19 , false , "[email protected] /foo/bar" , "123123" , @"src\dir\file1.cs" , - 1 , - 1 , "https://github.com/foo/bar/blob/123123/src/dir/file1.cs" ) ] 5562 [ InlineData ( 20 , false , "[email protected] /foo/bar" , "123123" , @"src\dir\File1.cs" , - 1 , - 1 , "https://github.com/foo/bar/blob/123123/src/dir/File1.cs" ) ] 5663 [ InlineData ( 21 , false , "[email protected] /foo/bar" , "123123" , @"src\dir\ThisIsFile1.cs" , - 1 , - 1 , "https://github.com/foo/bar/blob/123123/src/dir/ThisIsFile1.cs" ) ] 57- public void GenerateUrl ( int testid , bool createRootedPath , string baseUrl , string sha , string path , int startLine , int endLine , string expected )
64+ public async void GenerateUrl ( int testid , bool createRootedPath , string baseUrl , string sha , string path , int startLine , int endLine , string expected )
5865 {
5966 using ( var temp = new TempDirectory ( ) )
6067 {
@@ -68,7 +75,7 @@ public void GenerateUrl(int testid, bool createRootedPath, string baseUrl, strin
6875 model = new LocalRepositoryModel ( "bar" , new UriString ( baseUrl ) , basePath . FullName ) ;
6976 else
7077 model = new LocalRepositoryModel ( basePath . FullName ) ;
71- var result = model . GenerateUrl ( path , startLine , endLine ) ;
78+ var result = await model . GenerateUrl ( path , startLine , endLine ) ;
7279 Assert . Equal ( expected , result ? . ToString ( ) ) ;
7380 }
7481 }
0 commit comments