@@ -9,7 +9,8 @@ namespace PactNet.ConsumerOne.UnitTest
99 public class ReportCardControllerTest
1010 {
1111 private readonly IPactBuilderV3 _pactBuilder ;
12-
12+ private const string ValidStudentId = "067a50c5-0b23-485e-b018-17c66b2422ff" ;
13+
1314 public ReportCardControllerTest ( )
1415 {
1516 var pactDir =
@@ -33,8 +34,8 @@ public async Task Get_Student_When_The_Student_With_Id_1_Exists()
3334 // Arrange
3435 _pactBuilder
3536 . UponReceiving ( "A GET request to retrieve the student" )
36- . Given ( "There is student with id 1 " )
37- . WithRequest ( HttpMethod . Get , "/students/" + 1 )
37+ . Given ( $ "There is student with id { ValidStudentId } ")
38+ . WithRequest ( HttpMethod . Get , $ "/students/{ ValidStudentId } " )
3839 . WithHeader ( "Accept" , "application/json" )
3940 . WillRespond ( )
4041 . WithStatus ( HttpStatusCode . OK )
@@ -44,17 +45,17 @@ public async Task Get_Student_When_The_Student_With_Id_1_Exists()
4445 firstName = "Raju" ,
4546 lastName = "Rastogi" ,
4647 address = "Delhi" ,
47- id = 1
48+ id = ValidStudentId
4849 } ) ;
4950
5051 await _pactBuilder . VerifyAsync ( async ctx =>
5152 {
5253 // Act
5354 var client = new StudentClient ( ctx . MockServerUri ) ;
54- var studentDto = await client . GetStudentById ( 1 ) ;
55+ var studentDto = await client . GetStudentById ( ValidStudentId ) ;
5556
5657 // Assert
57- Assert . That ( studentDto . Id , Is . EqualTo ( 1 ) ) ;
58+ Assert . That ( studentDto . Id , Is . EqualTo ( ValidStudentId ) ) ;
5859 } ) ;
5960 }
6061
@@ -65,7 +66,7 @@ public void Get_Student_When_The_StudentId_Is_Invalid()
6566 _pactBuilder
6667 . UponReceiving ( "A GET request to retrieve the student with invalid student id" )
6768 . Given ( "There is student is at least one valid student present" )
68- . WithRequest ( HttpMethod . Get , "/students/" + - 999 )
69+ . WithRequest ( HttpMethod . Get , "/students/some-invalid-id" )
6970 . WithHeader ( "Accept" , "application/json" )
7071 . WillRespond ( )
7172 . WithStatus ( HttpStatusCode . NoContent ) ;
@@ -74,7 +75,7 @@ public void Get_Student_When_The_StudentId_Is_Invalid()
7475 {
7576 // Act
7677 var client = new StudentClient ( ctx . MockServerUri ) ;
77- Assert . ThrowsAsync < Exception > ( async ( ) => await client . GetStudentById ( - 999 ) ) ;
78+ Assert . ThrowsAsync < Exception > ( async ( ) => await client . GetStudentById ( "some-invalid-id" ) ) ;
7879 } ) ;
7980 }
8081 }
0 commit comments