Skip to content

Commit c03f3ce

Browse files
committed
Updated integration tests
1 parent 2e090df commit c03f3ce

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAuthTest.cs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ public async Task SetCustomUserClaimsWithWrongUid()
118118
{
119119
var customClaims = new Dictionary<string, object>();
120120

121-
await Assert.ThrowsAsync<FirebaseException>(
121+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
122122
async () => await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync("non.existing", customClaims));
123+
124+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
123125
}
124126

125127
[Fact]
@@ -150,8 +152,10 @@ public async Task CreateUserWithParams()
150152
Assert.False(user.Disabled);
151153

152154
// Cannot recreate the same user.
153-
await Assert.ThrowsAsync<FirebaseException>(
155+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
154156
async () => await FirebaseAuth.DefaultInstance.CreateUserAsync(args));
157+
158+
Assert.Equal(AuthErrorCode.UidAlreadyExists, exception.AuthErrorCode);
155159
}
156160
finally
157161
{
@@ -247,23 +251,29 @@ public async Task UserLifecycle()
247251
{
248252
// Delete user
249253
await FirebaseAuth.DefaultInstance.DeleteUserAsync(uid);
250-
await Assert.ThrowsAsync<FirebaseException>(
254+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
251255
async () => await FirebaseAuth.DefaultInstance.GetUserAsync(uid));
256+
257+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
252258
}
253259
}
254260

255261
[Fact]
256262
public async Task GetUserNonExistingUid()
257263
{
258-
await Assert.ThrowsAsync<FirebaseException>(
264+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
259265
async () => await FirebaseAuth.DefaultInstance.GetUserAsync("non.existing"));
266+
267+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
260268
}
261269

262270
[Fact]
263271
public async Task GetUserNonExistingEmail()
264272
{
265-
await Assert.ThrowsAsync<FirebaseException>(
273+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
266274
async () => await FirebaseAuth.DefaultInstance.GetUserByEmailAsync("[email protected]"));
275+
276+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
267277
}
268278

269279
[Fact]
@@ -273,15 +283,20 @@ public async Task UpdateUserNonExistingUid()
273283
{
274284
Uid = "non.existing",
275285
};
276-
await Assert.ThrowsAsync<FirebaseException>(
286+
287+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
277288
async () => await FirebaseAuth.DefaultInstance.UpdateUserAsync(args));
289+
290+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
278291
}
279292

280293
[Fact]
281294
public async Task DeleteUserNonExistingUid()
282295
{
283-
await Assert.ThrowsAsync<FirebaseException>(
296+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
284297
async () => await FirebaseAuth.DefaultInstance.DeleteUserAsync("non.existing"));
298+
299+
Assert.Equal(AuthErrorCode.UserNotFound, exception.AuthErrorCode);
285300
}
286301

287302
[Fact]

0 commit comments

Comments
 (0)