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)
35
35
return await _client . PostAsJsonAsync ( "/Account/v1/User" , user ) ;
36
36
}
37
37
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
+
38
53
public async Task < TokenResponseDto ? > GenerateTokenAsync ( UserRequestDto user )
39
54
{
40
55
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()
36
36
{
37
37
var books = await Client . GetAllBooksAsync ( ) ;
38
38
var isbn = books . Books . First ( ) . ISBN ;
39
-
40
39
var addRes = await Client . AddBookToUserAsync ( _userId , isbn , _token ) ;
41
40
Assert . That ( ( int ) addRes . StatusCode , Is . EqualTo ( 201 ) ) ;
42
41
}
43
42
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
+
44
56
[ Test ]
45
57
public async Task DeleteBookFromUser_ShouldReturn204 ( )
46
58
{
You can’t perform that action at this time.
0 commit comments