@@ -30,7 +30,7 @@ public async void GetCommitBySha()
3030 using ( var client = new HttpClient ( handler ) { BaseAddress = new Uri ( gitlabServer ) } )
3131 {
3232 var gitlabHttpFacade = new GitLabHttpFacade ( new RequestsJsonSerializer ( ) , client ) ;
33- var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) ) ;
33+ var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) , new CommitStatusesQueryBuilder ( ) ) ;
3434
3535 var commitFromClient = await commitsClient . GetAsync ( projectId , sha ) ;
3636 commitFromClient . Id . Should ( ) . BeEquivalentTo ( sha ) ;
@@ -52,7 +52,7 @@ public async void GetCommitsByRefName()
5252 using ( var client = new HttpClient ( handler ) { BaseAddress = new Uri ( gitlabServer ) } )
5353 {
5454 var gitlabHttpFacade = new GitLabHttpFacade ( new RequestsJsonSerializer ( ) , client ) ;
55- var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) ) ;
55+ var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) , new CommitStatusesQueryBuilder ( ) ) ;
5656
5757 var commitsFromClient = await commitsClient . GetAsync ( projectId , o => o . RefName = refName ) ;
5858 commitsFromClient [ 0 ] . Id . Should ( ) . BeEquivalentTo ( "id1" ) ;
@@ -76,7 +76,7 @@ public async void GetDiffsForCommit()
7676 using ( var client = new HttpClient ( handler ) { BaseAddress = new Uri ( gitlabServer ) } )
7777 {
7878 var gitlabHttpFacade = new GitLabHttpFacade ( new RequestsJsonSerializer ( ) , client ) ;
79- var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) ) ;
79+ var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) , new CommitStatusesQueryBuilder ( ) ) ;
8080
8181 var diffsFromClient = await commitsClient . GetDiffsAsync ( projectId , sha ) ;
8282 diffsFromClient [ 0 ] . DiffText . Should ( ) . BeEquivalentTo ( "diff1" ) ;
@@ -99,5 +99,37 @@ public async void GetDiffsForCommit()
9999
100100 }
101101 }
102+
103+ [ Fact ]
104+ public async void GetStatusesForCommit ( )
105+ {
106+ string gitlabServer = "http://fake-gitlab.com/" ;
107+ string projectId = "id" ;
108+ string sha = "6104942438c14ec7bd21c6cd5bd995272b3faff6" ;
109+ string Name = "name1" ;
110+ string url = $ "/projects/id/repository/commits/{ sha } /statuses?name={ Name } &per_page=100&page=1";
111+
112+ var handler = A . Fake < MockHandler > ( opt => opt . CallsBaseMethods ( ) ) ;
113+ A . CallTo ( ( ) => handler . SendAsync ( HttpMethod . Get , url ) )
114+ . ReturnsLazily ( ( ) => HttpResponseMessageProducer . Success (
115+ $ "[ {{\" id\" :1,\" sha\" :\" { sha } \" ,\" ref \" :\" \" ,\" status\" :\" success\" ,\" name\" :\" name1\" ,\" target_url\" :\" target_url1\" ,\" description\" :\" success\" ,\" created_at\" :\" 2020-04-08T11:57:49.136+05:30\" ,\" started_at\" :\" 2020-04-08T11:58:00.362+05:30\" ,\" finished_at\" :\" 2020-04-08T11:58:06.121+05:30\" ,\" allow_failure\" :false,\" coverage\" :null,\" author\" :{{\" id\" :1,\" name\" :\" name\" ,\" username\" :\" username\" ,\" state\" :\" active\" ,\" avatar_url\" :\" avatar_url1\" ,\" web_url\" :\" web_url1\" }} }},{{\" id\" :2,\" sha\" :\" { sha } \" ,\" ref \" :\" \" ,\" status\" :\" success\" ,\" name\" :\" name2\" ,\" target_url\" :\" target_url2\" ,\" description\" :\" success\" ,\" created_at\" :\" 2020-04-08T11:57:49.136+05:30\" ,\" started_at\" :\" 2020-04-08T11:58:00.362+05:30\" ,\" finished_at\" :\" 2020-04-08T11:58:06.121+05:30\" ,\" allow_failure\" :false,\" coverage\" :null,\" author\" :{{\" id\" :2,\" name\" :\" name2\" ,\" username\" :\" username2\" ,\" state\" :\" activ2\" ,\" avatar_url2\" :\" avatar_url2\" ,\" web_url\" :\" web_url2\" }} }}]") ) ;
116+ using ( var client = new HttpClient ( handler ) { BaseAddress = new Uri ( gitlabServer ) } )
117+ {
118+ var gitlabHttpFacade = new GitLabHttpFacade ( new RequestsJsonSerializer ( ) , client ) ;
119+ var commitsClient = new CommitsClient ( gitlabHttpFacade , new CommitQueryBuilder ( ) , new CommitRefsQueryBuilder ( ) , new CommitStatusesQueryBuilder ( ) ) ;
120+
121+ var statusesFromClient = await commitsClient . GetStatusesAsync ( projectId , sha , o => o . Name = Name ) ;
122+ statusesFromClient [ 0 ] . Status . Should ( ) . BeEquivalentTo ( "success" ) ;
123+ statusesFromClient [ 0 ] . Name . Should ( ) . BeEquivalentTo ( "name1" ) ;
124+ statusesFromClient [ 0 ] . Target_url . Should ( ) . BeEquivalentTo ( "target_url1" ) ;
125+ statusesFromClient [ 0 ] . Id . Should ( ) . BeEquivalentTo ( "1" ) ;
126+
127+ statusesFromClient [ 1 ] . Status . Should ( ) . BeEquivalentTo ( "success" ) ;
128+ statusesFromClient [ 1 ] . Name . Should ( ) . BeEquivalentTo ( "name2" ) ;
129+ statusesFromClient [ 1 ] . Target_url . Should ( ) . BeEquivalentTo ( "target_url2" ) ;
130+ statusesFromClient [ 1 ] . Id . Should ( ) . BeEquivalentTo ( "2" ) ;
131+
132+ }
133+ }
102134 }
103135}
0 commit comments