@@ -96,6 +96,11 @@ public void NoEmail()
9696 var handler = new MockMessageHandler ( ) { Response = GenerateEmailLinkResponse } ;
9797 var auth = this . CreateFirebaseAuth ( handler ) ;
9898
99+ Assert . ThrowsAsync < ArgumentException > (
100+ async ( ) => await auth . GenerateEmailVerificationLinkAsync ( null ) ) ;
101+ Assert . ThrowsAsync < ArgumentException > (
102+ async ( ) => await auth . GenerateEmailVerificationLinkAsync ( string . Empty ) ) ;
103+
99104 Assert . ThrowsAsync < ArgumentException > (
100105 async ( ) => await auth . GeneratePasswordResetLinkAsync ( null ) ) ;
101106 Assert . ThrowsAsync < ArgumentException > (
@@ -110,10 +115,79 @@ public void InvalidActionCodeSettings(ActionCodeSettings settings)
110115 var auth = this . CreateFirebaseAuth ( handler ) ;
111116112117
118+ Assert . ThrowsAsync < ArgumentException > (
119+ async ( ) => await auth . GenerateEmailVerificationLinkAsync ( email , settings ) ) ;
120+
113121 Assert . ThrowsAsync < ArgumentException > (
114122 async ( ) => await auth . GeneratePasswordResetLinkAsync ( email , settings ) ) ;
115123 }
116124
125+ [ Fact ]
126+ public async Task EmailVerificationLink ( )
127+ {
128+ var handler = new MockMessageHandler ( ) { Response = GenerateEmailLinkResponse } ;
129+ var auth = this . CreateFirebaseAuth ( handler ) ;
130+
131+ var link = await auth . GenerateEmailVerificationLinkAsync ( "[email protected] " ) ; 132+
133+ Assert . Equal ( "https://mock-oob-link.for.auth.tests" , link ) ;
134+
135+ var request = NewtonsoftJsonSerializer . Instance . Deserialize < Dictionary < string , object > > (
136+ handler . LastRequestBody ) ;
137+ Assert . Equal ( 3 , request . Count ) ;
138+ Assert . Equal ( "[email protected] " , request [ "email" ] ) ; 139+ Assert . Equal ( "VERIFY_EMAIL" , request [ "requestType" ] ) ;
140+ Assert . True ( ( bool ) request [ "returnOobLink" ] ) ;
141+ this . AssertRequest ( handler . Requests [ 0 ] ) ;
142+ }
143+
144+ [ Fact ]
145+ public async Task EmailVerificationLinkWithSettings ( )
146+ {
147+ var handler = new MockMessageHandler ( ) { Response = GenerateEmailLinkResponse } ;
148+ var auth = this . CreateFirebaseAuth ( handler ) ;
149+
150+ var link = await auth . GenerateEmailVerificationLinkAsync (
151+ "[email protected] " , ActionCodeSettings ) ; 152+
153+ Assert . Equal ( "https://mock-oob-link.for.auth.tests" , link ) ;
154+
155+ var request = NewtonsoftJsonSerializer . Instance . Deserialize < Dictionary < string , object > > (
156+ handler . LastRequestBody ) ;
157+ Assert . Equal ( 10 , request . Count ) ;
158+ Assert . Equal ( "[email protected] " , request [ "email" ] ) ; 159+ Assert . Equal ( "VERIFY_EMAIL" , request [ "requestType" ] ) ;
160+ Assert . True ( ( bool ) request [ "returnOobLink" ] ) ;
161+
162+ Assert . Equal ( ActionCodeSettings . Url , request [ "continueUrl" ] ) ;
163+ Assert . True ( ( bool ) request [ "canHandleCodeInApp" ] ) ;
164+ Assert . Equal ( ActionCodeSettings . DynamicLinkDomain , request [ "dynamicLinkDomain" ] ) ;
165+ Assert . Equal ( ActionCodeSettings . IosBundleId , request [ "iOSBundleId" ] ) ;
166+ Assert . Equal ( ActionCodeSettings . AndroidPackageName , request [ "androidPackageName" ] ) ;
167+ Assert . Equal (
168+ ActionCodeSettings . AndroidMinimumVersion , request [ "androidMinimumVersion" ] ) ;
169+ Assert . True ( ( bool ) request [ "androidInstallApp" ] ) ;
170+ this . AssertRequest ( handler . Requests [ 0 ] ) ;
171+ }
172+
173+ [ Fact ]
174+ public async Task EmailVerificationLinkUnexpectedResponse ( )
175+ {
176+ var handler = new MockMessageHandler ( ) { Response = "{}" } ;
177+ var auth = this . CreateFirebaseAuth ( handler ) ;
178+
179+ var exception = await Assert . ThrowsAsync < FirebaseAuthException > (
180+ async ( ) => await auth . GenerateEmailVerificationLinkAsync ( "[email protected] " ) ) ; 181+
182+ Assert . Equal ( ErrorCode . Unknown , exception . ErrorCode ) ;
183+ Assert . Equal ( AuthErrorCode . UnexpectedResponse , exception . AuthErrorCode ) ;
184+ Assert . Equal (
185+ $ "Failed to generate email action link for: [email protected] ", 186+ exception . Message ) ;
187+ Assert . NotNull ( exception . HttpResponse ) ;
188+ Assert . Null ( exception . InnerException ) ;
189+ }
190+
117191 [ Fact ]
118192 public async Task PasswordResetLink ( )
119193 {
0 commit comments