本文整理汇总了C#中RuntimeFlavor类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeFlavor类的具体用法?C# RuntimeFlavor怎么用?C# RuntimeFlavor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeFlavor类属于命名空间,在下文中一共展示了RuntimeFlavor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunSite
private async Task RunSite(ServerType server, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
{
await TestServices.RunSiteTest(
SiteName,
server,
runtimeFlavor,
architecture,
applicationBaseUrl,
async (httpClient, logger, token) =>
{
// ===== English =====
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger, token, retryCount: 30);
var responseText = await response.Content.ReadAsStringAsync();
var headingIndex = responseText.IndexOf("<h2>Application uses</h2>");
Assert.True(headingIndex >= 0);
// ===== French =====
response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync("?culture=fr&ui-culture=fr");
}, logger, token, retryCount: 30);
responseText = await response.Content.ReadAsStringAsync();
headingIndex = responseText.IndexOf("<h2>Utilisations d'application</h2>");
Assert.True(headingIndex >= 0);
});
}
示例2: ExistingPage
private async Task ExistingPage(ServerType server, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
{
await TestServices.RunSiteTest(
SiteName,
server,
runtimeFlavor,
architecture,
applicationBaseUrl,
async (httpClient, logger, token) =>
{
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger, token, retryCount: 30);
var responseText = await response.Content.ReadAsStringAsync();
logger.LogResponseOnFailedAssert(response, responseText, () =>
{
string expectedText = "Hello World, try /bob to get a 404";
Assert.Equal(expectedText, responseText);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
});
});
}
示例3: RunSiteTest
public static async Task RunSiteTest(string siteName, ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl,
Func<HttpClient, ILogger, CancellationToken, Task> validator)
{
var logger = new LoggerFactory()
.AddConsole()
.CreateLogger(string.Format("{0}:{1}:{2}:{3}", siteName, serverType, runtimeFlavor, architecture));
using (logger.BeginScope("RunSiteTest"))
{
var deploymentParameters = new DeploymentParameters(GetPathToApplication(siteName), serverType, runtimeFlavor, architecture)
{
ApplicationBaseUriHint = applicationBaseUrl,
SiteName = "HttpTestSite",
};
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(10)
};
await validator(httpClient, logger, deploymentResult.HostShutdownToken);
}
}
}
示例4: DeploymentParameters
/// <summary>
/// Creates an instance of <see cref="DeploymentParameters"/>.
/// </summary>
/// <param name="applicationPath">Source code location of the target location to be deployed.</param>
/// <param name="serverType">Where to be deployed on.</param>
/// <param name="runtimeFlavor">Flavor of the clr to run against.</param>
/// <param name="runtimeArchitecture">Architecture of the runtime to be used.</param>
public DeploymentParameters(
string applicationPath,
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture runtimeArchitecture)
{
if (string.IsNullOrEmpty(applicationPath))
{
throw new ArgumentException("Value cannot be null.", nameof(applicationPath));
}
if (!Directory.Exists(applicationPath))
{
throw new DirectoryNotFoundException(string.Format("Application path {0} does not exist.", applicationPath));
}
if (runtimeArchitecture == RuntimeArchitecture.x86)
{
throw new NotSupportedException("32 bit compilation is not yet supported. Don't remove the tests, just disable them for now.");
}
ApplicationPath = applicationPath;
ServerType = serverType;
RuntimeFlavor = runtimeFlavor;
EnvironmentVariables.Add(new KeyValuePair<string, string>("ASPNETCORE_DETAILEDERRORS", "true"));
}
示例5: RunSite
private async Task RunSite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
{
await TestServices.RunSiteTest(
SiteName,
serverType,
runtimeFlavor,
architecture,
applicationBaseUrl,
async (httpClient, logger, token) =>
{
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger, token, retryCount: 30);
var responseText = await response.Content.ReadAsStringAsync();
string expectedText =
"Retry Count 42\r\n" +
"Default Ad Block House\r\n" +
"Ad Block Contoso Origin sql-789 Product Code contoso2014\r\n" +
"Ad Block House Origin blob-456 Product Code 123\r\n";
logger.LogResponseOnFailedAssert(response, responseText, () =>
{
Assert.Equal(expectedText, responseText);
});
});
}
示例6: OpenIdConnect_OnX86
public async Task OpenIdConnect_OnX86(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
string applicationBaseUrl)
{
await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl);
}
示例7: NtlmAuthenticationTest
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
{
var logger = new LoggerFactory()
.AddConsole(LogLevel.Warning)
.CreateLogger(string.Format("Ntlm:{0}:{1}:{2}", serverType, runtimeFlavor, architecture));
using (logger.BeginScope("NtlmAuthenticationTest"))
{
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
var connectionString = string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName);
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(), serverType, runtimeFlavor, architecture)
{
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
ApplicationHostConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null,
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
UserAdditionalCleanup = parameters =>
{
if (!Helpers.RunningOnMono)
{
// Mono uses InMemoryStore
DbUtils.DropDatabase(musicStoreDbName, logger);
}
}
};
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
"SQLAZURECONNSTR_DefaultConnection",
string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
await validator.VerifyNtlmHomePage(response);
//Should be able to access the store as the Startup adds necessary permissions for the current user
await validator.AccessStoreWithPermissions();
logger.LogInformation("Variation completed successfully.");
}
}
}
示例8: HelloWorld
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, ServerType delegateServer, ApplicationType applicationType)
{
var logger = new LoggerFactory()
.AddConsole()
.AddDebug()
.CreateLogger($"HelloWorld:{serverType}:{runtimeFlavor}:{architecture}:{delegateServer}");
using (logger.BeginScope("HelloWorldTest"))
{
var deploymentParameters = new DeploymentParameters(Helpers.GetTestSitesPath(applicationType), serverType, runtimeFlavor, architecture)
{
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
SiteName = "HttpTestSite", // This is configured in the Http.config
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0",
ApplicationType = applicationType
};
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(5),
};
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(() =>
{
return httpClient.GetAsync(string.Empty);
}, logger, deploymentResult.HostShutdownToken, retryCount: 30);
var responseText = await response.Content.ReadAsStringAsync();
try
{
Assert.Equal("Hello World", responseText);
response = await httpClient.GetAsync("/Path%3F%3F?query");
responseText = await response.Content.ReadAsStringAsync();
Assert.Equal("/Path??", responseText);
response = await httpClient.GetAsync("/Query%3FPath?query?");
responseText = await response.Content.ReadAsStringAsync();
Assert.Equal("?query?", responseText);
}
catch (XunitException)
{
logger.LogWarning(response.ToString());
logger.LogWarning(responseText);
throw;
}
}
}
}
示例9: OpenIdConnectTestSuite
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl)
{
var logger = new LoggerFactory()
.AddConsole(LogLevel.Warning)
.CreateLogger(string.Format("OpenId:{0}:{1}:{2}", serverType, runtimeFlavor, architecture));
using (logger.BeginScope("OpenIdConnectTestSuite"))
{
var musicStoreDbName = Guid.NewGuid().ToString().Replace("-", string.Empty);
var connectionString = string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName);
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(), serverType, runtimeFlavor, architecture)
{
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "OpenIdConnectTesting",
UserAdditionalCleanup = parameters =>
{
if (!Helpers.RunningOnMono
&& TestPlatformHelper.IsWindows)
{
// Mono uses InMemoryStore
DbUtils.DropDatabase(musicStoreDbName, logger);
}
}
};
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
"SQLAZURECONNSTR_DefaultConnection",
string.Format(DbUtils.CONNECTION_STRING_FORMAT, musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false };
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
await validator.VerifyHomePage(response);
// OpenIdConnect login.
await validator.LoginWithOpenIdConnect();
logger.LogInformation("Variation completed successfully.");
}
}
}
示例10: NonWindowsOS
public async Task NonWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
string applicationBaseUrl)
{
var smokeTestRunner = new SmokeTests();
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl);
}
示例11: WindowsOS
public async Task WindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
string applicationBaseUrl,
bool noSource)
{
var testRunner = new PublishAndRunTests(_logger);
await testRunner.Publish_And_Run_Tests(
serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource);
}
示例12: NtlmAuthenticationTest
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
{
using (_logger.BeginScope("NtlmAuthenticationTest"))
{
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
PublishApplicationBeforeDeployment = true,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0",
ApplicationType = applicationType,
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("NtlmAuthentation.config") : null,
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, _logger);
}
};
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStore.StoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);
Console.WriteLine("Verifying home page");
await validator.VerifyNtlmHomePage(response);
Console.WriteLine("Verifying access to store with permissions");
await validator.AccessStoreWithPermissions();
_logger.LogInformation("Variation completed successfully.");
}
}
}
示例13: Localization_ResourcesInFolder_ReturnNonLocalizedValue_CultureHierarchyTooDeep_Windows
public Task Localization_ResourcesInFolder_ReturnNonLocalizedValue_CultureHierarchyTooDeep_Windows(
RuntimeFlavor runtimeFlavor,
string applicationBaseUrl,
RuntimeArchitecture runtimeArchitechture)
{
var testRunner = new TestRunner();
return testRunner.RunTestAndVerifyResponse(
runtimeFlavor,
runtimeArchitechture,
applicationBaseUrl,
"ResourcesInFolder",
"fr-FR-test-again-too-deep-to-work",
"Hello Hello Hello");
}
示例14: Localization_ResourcesInFolder_ReturnLocalizedValue_WithCultureFallback_Windows
public Task Localization_ResourcesInFolder_ReturnLocalizedValue_WithCultureFallback_Windows(
RuntimeFlavor runtimeFlavor,
string applicationBaseUrl,
RuntimeArchitecture runtimeArchitechture)
{
var testRunner = new TestRunner();
return testRunner.RunTestAndVerifyResponse(
runtimeFlavor,
runtimeArchitechture,
applicationBaseUrl,
"ResourcesInFolder",
"fr-FR-test",
"Bonjour from StartupResourcesInFolder Bonjour from Test in resources folder Bonjour from Customer in resources folder");
}
示例15: Localization_ResourcesAtRootFolder_ReturnLocalizedValue_Mono
public Task Localization_ResourcesAtRootFolder_ReturnLocalizedValue_Mono(
RuntimeFlavor runtimeFlavor,
string applicationBaseUrl,
RuntimeArchitecture runtimeArchitechture)
{
var testRunner = new TestRunner();
return testRunner.RunTestAndVerifyResponse(
runtimeFlavor,
runtimeArchitechture,
applicationBaseUrl,
"ResourcesAtRootFolder",
"fr-FR",
"Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in root folder");
}