本文整理汇总了C#中ApplicationUserManager.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUserManager.Expect方法的具体用法?C# ApplicationUserManager.Expect怎么用?C# ApplicationUserManager.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApplicationUserManager
的用法示例。
在下文中一共展示了ApplicationUserManager.Expect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItDoesntSignInIfTheUserIsntCreatedSuccessfully
public async Task ItDoesntSignInIfTheUserIsntCreatedSuccessfully()
{
newUser = new NewUser();
IdentityResult result = new IdentityResult("an error");
applicationUserManagerMock = MockRepository.GenerateMock<ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
applicationUserManagerMock.Expect(mock => mock.CreateAsync(Arg<ApplicationUser>.Is.Anything, Arg<string>.Is.Anything))
.Return(Task.FromResult<IdentityResult>(result));
userRegisterer = new UserRegisterer(
applicationUserManagerMock,
firstTimeUserAuthenticatorMock,
dataContextMock,
signInManagerMock,
eventTrackerMock,
gamingGroupInviteConsumerMock);
await userRegisterer.RegisterUser(newUser);
firstTimeUserAuthenticatorMock.AssertWasNotCalled(mock => mock.CreateGamingGroupAndSendEmailConfirmation(
Arg<ApplicationUser>.Is.Anything,
Arg<TransactionSource>.Is.Anything));
}
示例2: SetUp
public void SetUp()
{
firstTimeUserAuthenticatorMock = MockRepository.GenerateMock<IFirstTimeAuthenticator>();
userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
var dataProtector = MockRepository.GenerateMock<IDataProtector>();
dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);
applicationUserManagerMock = MockRepository.GenerateMock<ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
authenticationManagerMock = MockRepository.GenerateMock<IAuthenticationManager>();
signInManagerMock = MockRepository.GenerateMock<ApplicationSignInManager>(applicationUserManagerMock, authenticationManagerMock);
dataContextMock = MockRepository.GenerateMock<IDataContext>();
eventTrackerMock = MockRepository.GenerateMock<INemeStatsEventTracker>();
gamingGroupInviteConsumerMock = MockRepository.GenerateMock<IGamingGroupInviteConsumer>();
userRegisterer = new UserRegisterer(
applicationUserManagerMock,
firstTimeUserAuthenticatorMock,
dataContextMock,
signInManagerMock,
eventTrackerMock,
gamingGroupInviteConsumerMock);
Guid invitationId = Guid.NewGuid();
const int PLAYER_ID = 1938;
GamingGroupInvitation invitation = new GamingGroupInvitation
{
Id = invitationId,
PlayerId = PLAYER_ID,
GamingGroupId = 10
};
newUser = new NewUser()
{
UserName = "user name",
EmailAddress = "the email",
GamingGroupInvitationId = invitationId,
Source = TransactionSource.WebApplication
};
expectedNewlyRegisteredUser = new NewlyRegisteredUser
{
GamingGroupId = invitation.GamingGroupId,
GamingGroupName = "some awesome gaming group name",
PlayerId = PLAYER_ID,
PlayerName = "some awesome player name",
UserId = applicationUserIdAfterSaving
};
IdentityResult result = IdentityResult.Success;
dataContextMock.Expect(mock => mock.FindById<GamingGroupInvitation>(invitationId))
.Return(invitation);
applicationUserManagerMock.Expect(mock => mock.CreateAsync(Arg<ApplicationUser>.Is.Anything, Arg<string>.Is.Anything))
.Return(Task.FromResult(result))
.WhenCalled(invocation => ((ApplicationUser)invocation.Arguments[0]).Id = applicationUserIdAfterSaving);
signInManagerMock.Expect(mock => mock.SignInAsync(
Arg<ApplicationUser>.Is.Anything,
Arg<bool>.Is.Anything,
Arg<bool>.Is.Anything))
.Return(Task.FromResult(-1));
gamingGroupInviteConsumerMock.Expect(mock => mock.AddNewUserToGamingGroup(Arg<string>.Is.Anything, Arg<Guid>.Is.Anything))
.Return(expectedNewlyRegisteredUser);
firstTimeUserAuthenticatorMock.Expect(mock => mock.CreateGamingGroupAndSendEmailConfirmation(
Arg<ApplicationUser>.Is.Anything,
Arg<TransactionSource>.Is.Anything))
.Return(Task.FromResult(expectedNewlyRegisteredUser));
}
示例3: SetUp
public void SetUp()
{
var userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
var dataProtector = MockRepository.GenerateMock<IDataProtector>();
dataProtectionProviderMock = MockRepository.GenerateMock<IDataProtectionProvider>();
dataProtectionProviderMock.Expect(mock => mock.Create(Arg<string>.Is.Anything)).Return(dataProtector);
applicationUserManagerMock = MockRepository.GenerateMock<ApplicationUserManager>(userStoreMock, dataProtectionProviderMock);
gamingGroupSaverMock = MockRepository.GenerateMock<IGamingGroupSaver>();
configurationManagerMock = MockRepository.GenerateMock<IConfigurationManager>();
dataContextMock = MockRepository.GenerateMock<IDataContext>();
firstTimeAuthenticator = new FirstTimeAuthenticator(
gamingGroupSaverMock,
applicationUserManagerMock,
configurationManagerMock,
dataContextMock);
applicationUser = new ApplicationUser
{
Id = "user id",
UserName = "user name"
};
registrationSource = TransactionSource.RestApi;
var appSettingsMock = MockRepository.GenerateMock<IAppSettings>();
configurationManagerMock.Expect(mock => mock.AppSettings)
.Return(appSettingsMock);
appSettingsMock.Expect(mock => mock.Get(FirstTimeAuthenticator.APP_KEY_EMAIL_CONFIRMATION_CALLBACK_URL))
.Return(callbackUrl);
expectedNewlyCreatedGamingGroupResult = new NewlyCreatedGamingGroupResult
{
NewlyCreatedGamingGroup = new GamingGroup { Id = 1 },
NewlyCreatedPlayer = new Player { Id = 100, Name = "some awesome player name"}
};
gamingGroupSaverMock.Expect(mock => mock.CreateNewGamingGroup(
Arg<string>.Is.Anything,
Arg<TransactionSource>.Is.Anything,
Arg<ApplicationUser>.Is.Anything))
.Return(expectedNewlyCreatedGamingGroupResult);
applicationUserManagerMock.Expect(mock => mock.GenerateEmailConfirmationTokenAsync(applicationUser.Id))
.Return(Task.FromResult(confirmationToken));
string expectedCallbackUrl = callbackUrl + string.Format(
FirstTimeAuthenticator.CONFIRMATION_EMAIL_CALLBACK_URL_SUFFIX,
applicationUser.Id,
HttpUtility.UrlEncode(confirmationToken));
string expectedEmailBody = string.Format(FirstTimeAuthenticator.CONFIRMATION_EMAIL_BODY, expectedCallbackUrl);
applicationUserManagerMock.Expect(mock => mock.SendEmailAsync(
applicationUser.Id,
FirstTimeAuthenticator.EMAIL_SUBJECT,
expectedEmailBody))
.Return(Task.FromResult(-1));
}