本文整理汇总了C#中IConfigurationManager.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# IConfigurationManager.Expect方法的具体用法?C# IConfigurationManager.Expect怎么用?C# IConfigurationManager.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfigurationManager
的用法示例。
在下文中一共展示了IConfigurationManager.Expect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: SetUp
public void SetUp()
{
configurationManagerMock = MockRepository.GenerateMock<IConfigurationManager>();
appSettingsMock = MockRepository.GenerateMock<IAppSettings>();
configurationManagerMock.Expect(mock => mock.AppSettings)
.Return(appSettingsMock);
factory = new UniversalAnalyticsEventFactory(configurationManagerMock);
}
开发者ID:RIDGIDSoftwareSolutions,项目名称:Universal-Analytics-For-DotNet,代码行数:10,代码来源:UniversalAnalyticsEventFactoryTests.cs
示例3: SetUp
public void SetUp()
{
dataContextMock = MockRepository.GenerateMock<IDataContext>();
emailServiceMock = MockRepository.GenerateMock<IIdentityMessageService>();
configurationManagerMock = MockRepository.GenerateMock<IConfigurationManager>();
playerInvitation = new PlayerInvitation
{
CustomEmailMessage = "custom message",
EmailSubject = "email subject",
InvitedPlayerEmail = "player email",
InvitedPlayerId = 1
};
currentUser = new ApplicationUser
{
CurrentGamingGroupId = 15,
UserName = "Fergie Ferg"
};
player = new Player
{
Id = playerInvitation.InvitedPlayerId,
GamingGroupId = 135
};
gamingGroup = new GamingGroup
{
Id = currentUser.CurrentGamingGroupId,
Name = "jake's Gaming Group"
};
gamingGroupInvitation = new GamingGroupInvitation
{
Id = Guid.NewGuid()
};
dataContextMock.Expect(mock => mock.FindById<GamingGroup>(currentUser.CurrentGamingGroupId))
.Return(gamingGroup);
List<ApplicationUser> applicationUsers = new List<ApplicationUser>
{
new ApplicationUser
{
Email = playerInvitation.InvitedPlayerEmail,
Id = existingUserId
}
};
dataContextMock.Expect(mock => mock.GetQueryable<ApplicationUser>())
.Return(applicationUsers.AsQueryable());
dataContextMock.Expect(mock => mock.Save<GamingGroupInvitation>(Arg<GamingGroupInvitation>.Is.Anything, Arg<ApplicationUser>.Is.Anything))
.Return(gamingGroupInvitation);
configurationManagerMock.Expect(mock => mock.AppSettings[PlayerInviter.APP_SETTING_URL_ROOT])
.Return(rootUrl);
emailServiceMock.Expect(mock => mock.SendAsync(Arg<IdentityMessage>.Is.Anything))
.Return(Task.FromResult<object>(null));
playerInviter = new PlayerInviter(dataContextMock, emailServiceMock, configurationManagerMock);
}
示例4: ItThrowsAConfigurationExceptionIfTheCallbackUrlConfigSettingIsMissing
public async Task ItThrowsAConfigurationExceptionIfTheCallbackUrlConfigSettingIsMissing()
{
configurationManagerMock = MockRepository.GenerateMock<IConfigurationManager>();
var appSettingsMock = MockRepository.GenerateMock<IAppSettings>();
configurationManagerMock.Expect(mock => mock.AppSettings)
.Return(appSettingsMock);
appSettingsMock.Expect(mock => mock.Get(FirstTimeAuthenticator.APP_KEY_EMAIL_CONFIRMATION_CALLBACK_URL))
.Throw(new Exception());
firstTimeAuthenticator = new FirstTimeAuthenticator(
gamingGroupSaverMock,
applicationUserManagerMock,
configurationManagerMock,
dataContextMock);
string exceptionMessage = string.Empty;
try
{
await firstTimeAuthenticator.CreateGamingGroupAndSendEmailConfirmation(applicationUser, registrationSource);
}
catch (ConfigurationException expectedException)
{
exceptionMessage = expectedException.Message;
}
Assert.AreEqual(exceptionMessage, "Missing app setting with key: emailConfirmationCallbackUrl");
}