@@ -124,20 +124,58 @@ public async Task CreateCallsUpdateEmailStore()
124124 }
125125
126126 [ Fact ]
127- public async Task DeleteCallsStore ( )
127+ public async Task DeleteCallsStore_Success ( )
128128 {
129129 // Setup
130+ var testMeterFactory = new TestMeterFactory ( ) ;
131+ using var deleteUser = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Identity" , "aspnetcore.identity.delete_user" ) ;
132+
130133 var store = new Mock < IUserStore < PocoUser > > ( ) ;
131134 var user = new PocoUser { UserName = "Foo" } ;
132135 store . Setup ( s => s . DeleteAsync ( user , CancellationToken . None ) ) . ReturnsAsync ( IdentityResult . Success ) . Verifiable ( ) ;
133- var userManager = MockHelpers . TestUserManager ( store . Object ) ;
136+ var userManager = MockHelpers . TestUserManager ( store . Object , meterFactory : testMeterFactory ) ;
134137
135138 // Act
136139 var result = await userManager . DeleteAsync ( user ) ;
137140
138141 // Assert
139142 Assert . True ( result . Succeeded ) ;
140143 store . VerifyAll ( ) ;
144+
145+ Assert . Collection ( deleteUser . GetMeasurementSnapshot ( ) ,
146+ m => MetricsHelpers . AssertContainsTags ( m . Tags ,
147+ [
148+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.user_type" , "Microsoft.AspNetCore.Identity.Test.PocoUser" ) ,
149+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.result" , "success" )
150+ ] ) ) ;
151+ }
152+
153+ [ Fact ]
154+ public async Task DeleteCallsStore_Failure ( )
155+ {
156+ // Setup
157+ var testMeterFactory = new TestMeterFactory ( ) ;
158+ using var deleteUser = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Identity" , "aspnetcore.identity.delete_user" ) ;
159+
160+ var store = new Mock < IUserStore < PocoUser > > ( ) ;
161+ var user = new PocoUser { UserName = "Foo" } ;
162+ store . Setup ( s => s . DeleteAsync ( user , CancellationToken . None ) ) . ReturnsAsync ( IdentityResult . Failed ( new IdentityErrorDescriber ( ) . ConcurrencyFailure ( ) ) ) . Verifiable ( ) ;
163+ var userManager = MockHelpers . TestUserManager ( store . Object , meterFactory : testMeterFactory ) ;
164+
165+ // Act
166+ var result = await userManager . DeleteAsync ( user ) ;
167+
168+ // Assert
169+ Assert . False ( result . Succeeded ) ;
170+ store . VerifyAll ( ) ;
171+
172+ Assert . Collection ( deleteUser . GetMeasurementSnapshot ( ) ,
173+ m => MetricsHelpers . AssertContainsTags ( m . Tags ,
174+ [
175+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.user_type" , "Microsoft.AspNetCore.Identity.Test.PocoUser" ) ,
176+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.result" , "failure" ) ,
177+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.result_error_code" , "ConcurrencyFailure" )
178+ ] ) ) ;
141179 }
142180
143181 [ Fact ]
@@ -591,6 +629,7 @@ public async Task CheckPasswordWillRehashPasswordWhenNeeded()
591629 var testMeterFactory = new TestMeterFactory ( ) ;
592630 using var updateUser = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Identity" , "aspnetcore.identity.update_user" ) ;
593631 using var checkPassword = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Identity" , "aspnetcore.identity.check_password" ) ;
632+ using var verifyPassword = new MetricCollector < long > ( testMeterFactory , "Microsoft.AspNetCore.Identity" , "aspnetcore.identity.verify_password" ) ;
594633
595634 var store = new Mock < IUserPasswordStore < PocoUser > > ( ) ;
596635 var hasher = new Mock < IPasswordHasher < PocoUser > > ( ) ;
@@ -628,6 +667,11 @@ public async Task CheckPasswordWillRehashPasswordWhenNeeded()
628667 [
629668 KeyValuePair . Create < string , object > ( "aspnetcore.identity.user.password_result" , "success_rehash_needed" )
630669 ] ) ) ;
670+ Assert . Collection ( verifyPassword . GetMeasurementSnapshot ( ) ,
671+ m => MetricsHelpers . AssertContainsTags ( m . Tags ,
672+ [
673+ KeyValuePair . Create < string , object > ( "aspnetcore.identity.user.password_result" , "success_rehash_needed" )
674+ ] ) ) ;
631675 }
632676
633677 [ Fact ]
@@ -1245,9 +1289,9 @@ public async Task ManagerPublicNullChecks()
12451289 async ( ) => await manager . CreateAsync ( new PocoUser ( ) , null ) ) ;
12461290 await Assert . ThrowsAsync < ArgumentNullException > ( "user" , async ( ) => await manager . UpdateAsync ( null ) ) ;
12471291 await Assert . ThrowsAsync < ArgumentNullException > ( "user" , async ( ) => await manager . DeleteAsync ( null ) ) ;
1248- await Assert . ThrowsAsync < ArgumentNullException > ( "claim " , async ( ) => await manager . AddClaimAsync ( null , null ) ) ;
1249- await Assert . ThrowsAsync < ArgumentNullException > ( "claim " , async ( ) => await manager . ReplaceClaimAsync ( null , null , null ) ) ;
1250- await Assert . ThrowsAsync < ArgumentNullException > ( "claims " , async ( ) => await manager . AddClaimsAsync ( null , null ) ) ;
1292+ await Assert . ThrowsAsync < ArgumentNullException > ( "user " , async ( ) => await manager . AddClaimAsync ( null , null ) ) ;
1293+ await Assert . ThrowsAsync < ArgumentNullException > ( "user " , async ( ) => await manager . ReplaceClaimAsync ( null , null , null ) ) ;
1294+ await Assert . ThrowsAsync < ArgumentNullException > ( "user " , async ( ) => await manager . AddClaimsAsync ( null , null ) ) ;
12511295 await Assert . ThrowsAsync < ArgumentNullException > ( "userName" , async ( ) => await manager . FindByNameAsync ( null ) ) ;
12521296 await Assert . ThrowsAsync < ArgumentNullException > ( "login" , async ( ) => await manager . AddLoginAsync ( null , null ) ) ;
12531297 await Assert . ThrowsAsync < ArgumentNullException > ( "loginProvider" ,
0 commit comments