6
6
using FluentAssertions ;
7
7
using Microsoft . AspNetCore . Identity ;
8
8
using Moq ;
9
+ using VirtoCommerce . Platform . Core . Common ;
9
10
using VirtoCommerce . Platform . Core . Events ;
10
11
using VirtoCommerce . Platform . Core . Security ;
11
12
using VirtoCommerce . Platform . Core . Security . Events ;
@@ -23,7 +24,7 @@ public async Task Create_CheckEvents(ApplicationUser user, Action<IEvent>[] asse
23
24
//Arrange
24
25
25
26
var userStoreMock = new Mock < IUserStore < ApplicationUser > > ( ) ;
26
- userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user ) ;
27
+ userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user . CloneTyped ( ) ) ;
27
28
userStoreMock . Setup ( x => x . CreateAsync ( It . IsAny < ApplicationUser > ( ) , CancellationToken . None ) )
28
29
. ReturnsAsync ( IdentityResult . Success ) ;
29
30
var eventPublisher = new EventPublisherStub ( ) ;
@@ -63,10 +64,7 @@ public async Task ResetPassword_CheckEvents(ApplicationUser user, Action<IEvent>
63
64
{
64
65
//Arrange
65
66
var userStoreMock = new Mock < IUserStore < ApplicationUser > > ( ) ;
66
- userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user ) ;
67
- userStoreMock . As < IUserPasswordStore < ApplicationUser > > ( )
68
- . Setup ( x => x . SetPasswordHashAsync ( user , user . PasswordHash , CancellationToken . None ) )
69
- . Returns ( Task . CompletedTask ) ;
67
+ userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user . CloneTyped ( ) ) ;
70
68
var eventPublisher = new EventPublisherStub ( ) ;
71
69
72
70
var userManager = SecurityMockHelper . TestCustomUserManager ( userStoreMock , eventPublisher ) ;
@@ -88,10 +86,7 @@ public async Task ChangePassword_CheckEvents(ApplicationUser user, Action<IEvent
88
86
{
89
87
//Arrange
90
88
var userStoreMock = new Mock < IUserStore < ApplicationUser > > ( ) ;
91
- userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user ) ;
92
- userStoreMock . As < IUserPasswordStore < ApplicationUser > > ( )
93
- . Setup ( x => x . GetPasswordHashAsync ( It . IsAny < ApplicationUser > ( ) , It . IsAny < CancellationToken > ( ) ) )
94
- . ReturnsAsync ( user . PasswordHash ) ;
89
+ userStoreMock . Setup ( x => x . FindByIdAsync ( user . Id , CancellationToken . None ) ) . ReturnsAsync ( user . CloneTyped ( ) ) ;
95
90
var eventPublisher = new EventPublisherStub ( ) ;
96
91
97
92
var userManager = SecurityMockHelper . TestCustomUserManager ( userStoreMock , eventPublisher ) ;
@@ -164,6 +159,7 @@ public IEnumerator<object[]> GetEnumerator()
164
159
new Action < IEvent > [ ]
165
160
{
166
161
x => x . GetType ( ) . Should ( ) . Be < UserChangingEvent > ( ) ,
162
+ x => x . GetType ( ) . Should ( ) . Be < UserPasswordChangedEvent > ( ) ,
167
163
x => x . GetType ( ) . Should ( ) . Be < UserResetPasswordEvent > ( ) ,
168
164
}
169
165
} ;
@@ -183,6 +179,7 @@ public IEnumerator<object[]> GetEnumerator()
183
179
{
184
180
x => x . GetType ( ) . Should ( ) . Be < UserChangingEvent > ( ) ,
185
181
x => x . GetType ( ) . Should ( ) . Be < UserPasswordChangedEvent > ( ) ,
182
+ x => x . GetType ( ) . Should ( ) . Be < UserChangedPasswordEvent > ( ) ,
186
183
}
187
184
} ;
188
185
}
0 commit comments