File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,21 @@ public async Task<HttpResponseMessage> CreateUserAsync(UserRequestDto user)
3535 return await _client . PostAsJsonAsync ( "/Account/v1/User" , user ) ;
3636 }
3737
38+ public async Task < GetUserResponseDto > GetUserAsync ( string userId , string token )
39+ {
40+ Console . WriteLine ( $ "GET /Account/v1/User/{ userId } ") ;
41+
42+ var request = new HttpRequestMessage ( HttpMethod . Get , $ "/Account/v1/User/{ userId } ") ;
43+ request . Headers . Add ( "Authorization" , $ "Bearer { token } ") ;
44+
45+ var response = await _client . SendAsync ( request ) ;
46+ response . EnsureSuccessStatusCode ( ) ;
47+
48+ return await response . Content . ReadFromJsonAsync < GetUserResponseDto > ( )
49+ ?? new GetUserResponseDto ( ) ;
50+ }
51+
52+
3853 public async Task < TokenResponseDto ? > GenerateTokenAsync ( UserRequestDto user )
3954 {
4055 Console . WriteLine ( "POST /GenerateToken" ) ;
Original file line number Diff line number Diff line change 1+ namespace SeleniumTests . lib . models ;
2+
3+ public class GetUserResponseDto
4+ {
5+ public string UserId { get ; set ; } = string . Empty ;
6+ public string Username { get ; set ; } = string . Empty ;
7+ public List < BookDto > Books { get ; set ; } = new ( ) ;
8+ }
Original file line number Diff line number Diff line change @@ -36,11 +36,23 @@ public async Task AddBookToUser_ShouldReturn201()
3636 {
3737 var books = await Client . GetAllBooksAsync ( ) ;
3838 var isbn = books . Books . First ( ) . ISBN ;
39-
4039 var addRes = await Client . AddBookToUserAsync ( _userId , isbn , _token ) ;
4140 Assert . That ( ( int ) addRes . StatusCode , Is . EqualTo ( 201 ) ) ;
4241 }
4342
43+ [ Test ]
44+ public async Task Verify_ThatBooksBeenAdded_ShouldReturn200 ( )
45+ {
46+ var books = await Client . GetAllBooksAsync ( ) ;
47+ var isbn = books . Books . First ( ) . ISBN ;
48+ await Client . AddBookToUserAsync ( _userId , isbn , _token ) ;
49+
50+ var getRes = await Client . GetUserAsync ( _userId , _token ) ;
51+ Assert . That ( getRes , Is . Not . Null ) ;
52+ Assert . That ( getRes . Books , Is . Not . Empty ) ;
53+ Assert . That ( getRes . Books [ 0 ] . ISBN , Is . EqualTo ( isbn ) ) ;
54+ }
55+
4456 [ Test ]
4557 public async Task DeleteBookFromUser_ShouldReturn204 ( )
4658 {
You can’t perform that action at this time.
0 commit comments