@@ -15,13 +15,12 @@ partial class TapoClientTests {
1515 [ Test ]
1616 public async Task AuthenticateAsync_KLAP ( )
1717 {
18- await using var device = new PseudoTapoDevice ( ) {
19- FuncGenerateKlapAuthHash = ( _ , _ , authHash ) => defaultKlapCredentialProvider ! . GetKlapCredential ( null ) . WriteLocalAuthHash ( authHash . Span ) ,
20- } ;
21- var endPoint = device . Start ( ) ;
18+ var device = CommonPseudoTapoDevice . Configure (
19+ funcGenerateKlapAuthHash : ( _ , _ , authHash ) => defaultKlapCredentialProvider ! . GetKlapCredential ( null ) . WriteLocalAuthHash ( authHash . Span )
20+ ) ;
2221
2322 using var client = new TapoClient (
24- endPoint : endPoint
23+ endPoint : device . GetListenerEndPoint ( )
2524 ) ;
2625
2726 Assert . DoesNotThrowAsync (
@@ -44,13 +43,12 @@ public async Task AuthenticateAsync_KLAP()
4443 [ Test ]
4544 public async Task AuthenticateAsync_KLAP_Handshake1_AuthHashMismatch ( )
4645 {
47- await using var device = new PseudoTapoDevice ( ) {
48- FuncGenerateKlapAuthHash = ( _ , _ , authHash ) => authHash . Span . Clear ( )
49- } ;
50- var endPoint = device . Start ( ) ;
46+ var device = CommonPseudoTapoDevice . Configure (
47+ funcGenerateKlapAuthHash : ( _ , _ , authHash ) => authHash . Span . Clear ( )
48+ ) ;
5149
5250 using var client = new TapoClient (
53- endPoint : endPoint
51+ endPoint : device . GetListenerEndPoint ( )
5452 ) ;
5553
5654 var ex = Assert . ThrowsAsync < TapoAuthenticationException > (
@@ -72,14 +70,13 @@ public async Task AuthenticateAsync_KLAP_Handshake2_HttpNonSuccessStatusCode()
7270 {
7371 const HttpStatusCode Handshake2NonSuccessStatusCode = HttpStatusCode . Unauthorized ;
7472
75- await using var device = new PseudoTapoDevice ( ) {
76- FuncGenerateKlapAuthHash = ( _ , _ , authHash ) => defaultKlapCredentialProvider ! . GetKlapCredential ( null ) . WriteLocalAuthHash ( authHash . Span ) ,
77- FuncGenerateKlapHandshake2Response = _ => ( Handshake2NonSuccessStatusCode , Handshake2NonSuccessStatusCode . ToString ( ) ) ,
78- } ;
79- var endPoint = device . Start ( ) ;
73+ var device = CommonPseudoTapoDevice . Configure (
74+ funcGenerateKlapAuthHash : ( _ , _ , authHash ) => defaultKlapCredentialProvider ! . GetKlapCredential ( null ) . WriteLocalAuthHash ( authHash . Span ) ,
75+ funcGenerateKlapHandshake2Response : _ => ( Handshake2NonSuccessStatusCode , Handshake2NonSuccessStatusCode . ToString ( ) )
76+ ) ;
8077
8178 using var client = new TapoClient (
82- endPoint : endPoint
79+ endPoint : device . GetListenerEndPoint ( )
8380 ) ;
8481
8582 var ex = Assert . ThrowsAsync < TapoAuthenticationException > (
@@ -113,13 +110,12 @@ public async Task AuthenticateAsync_KLAP_IdentifyCredentialForIdentity(
113110 Type ? typeOfExpectedException
114111 )
115112 {
116- await using var device = new PseudoTapoDevice ( ) {
117- FuncGenerateKlapAuthHash = ( _ , _ , authHash ) => credentialForKlapAuthHash . WriteLocalAuthHash ( authHash . Span )
118- } ;
119- var endPoint = device . Start ( ) ;
113+ var device = CommonPseudoTapoDevice . Configure (
114+ funcGenerateKlapAuthHash : ( _ , _ , authHash ) => credentialForKlapAuthHash . WriteLocalAuthHash ( authHash . Span )
115+ ) ;
120116
121117 using var client = new TapoClient (
122- endPoint : endPoint
118+ endPoint : device . GetListenerEndPoint ( )
123119 ) ;
124120
125121 await Assert . ThatAsync (
0 commit comments