本文整理汇总了C#中Microsoft.WindowsAzure.Management.Test.Stubs.FileSystemHelper.CreateNewService方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystemHelper.CreateNewService方法的具体用法?C# FileSystemHelper.CreateNewService怎么用?C# FileSystemHelper.CreateNewService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Management.Test.Stubs.FileSystemHelper
的用法示例。
在下文中一共展示了FileSystemHelper.CreateNewService方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAzureWebRoleWillRecreateDeploymentSettings
public void AddAzureWebRoleWillRecreateDeploymentSettings()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string roleName = "WebRole1";
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
string settingsFilePath = Path.Combine(rootPath, Resources.SettingsFileName);
string originalDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(rootPath);
File.Delete(settingsFilePath);
Assert.IsFalse(File.Exists(settingsFilePath));
addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName };
addWebCmdlet.ExecuteCmdlet();
AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WebRole));
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
Assert.IsTrue(File.Exists(settingsFilePath));
Directory.SetCurrentDirectory(originalDirectory);
}
}
示例2: AddAzurePythonWebRoleProcess
public void AddAzurePythonWebRoleProcess()
{
var pyInstall = AddAzureDjangoWebRoleCommand.FindPythonInterpreterPath();
if (pyInstall == null)
{
Assert.Inconclusive("Python is not installed on this machine and therefore the Python tests cannot be run");
return;
}
string stdOut, stdErr;
ProcessHelper.StartAndWaitForProcess(
new ProcessStartInfo(
Path.Combine(pyInstall, "python.exe"),
String.Format("-m django.bin.django-admin")
),
out stdOut,
out stdErr
);
if (stdOut.IndexOf("django-admin.py") == -1)
{
Assert.Inconclusive("Django is not installed on this machine and therefore the Python tests cannot be run");
return;
}
using (FileSystemHelper files = new FileSystemHelper(this))
{
string roleName = "WebRole1";
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
addPythonWebCmdlet = new AddAzureDjangoWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime };
addPythonWebCmdlet.CommandRuntime = mockCommandRuntime;
string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePython, rootPath, roleName);
mockCommandRuntime.ResetPipelines();
addPythonWebCmdlet.ExecuteCmdlet();
AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PythonScaffolding, Resources.WebRole));
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName)));
Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, "manage.py")));
Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName, roleName)));
Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "__init__.py")));
Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "settings.py")));
Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "urls.py")));
Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "wsgi.py")));
}
}
示例3: AddAzureNodeWorkerRoleProcess
public void AddAzureNodeWorkerRoleProcess()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string roleName = "WorkerRole1";
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime };
string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreateNode, rootPath, roleName);
addNodeWorkerCmdlet.ExecuteCmdlet();
AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
}
}
示例4: EnableAzureMemcacheRoleProcess
public void EnableAzureMemcacheRoleProcess()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string cacheRoleName = "WorkerRole";
string webRoleName = "WebRole";
string expectedMessage = string.Format(Resources.EnableMemcacheMessage, webRoleName, cacheRoleName, Resources.MemcacheEndpointPort);
addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName };
addNodeWebCmdlet.ExecuteCmdlet();
addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
mockCommandRuntime.ResetPipelines();
enableCacheCmdlet.PassThru = true;
enableCacheCmdlet.CacheRuntimeVersion = "1.8.0";
enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath);
AssertCachingEnabled(files, serviceName, rootPath, webRoleName, expectedMessage);
}
}
示例5: AddAzureWebRoleWithMissingScaffoldXmlFail
public void AddAzureWebRoleWithMissingScaffoldXmlFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string roleName = "WebRole1";
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
string originalDirectory = Directory.GetCurrentDirectory();
string scaffoldingPath = "TemplateMissingScaffoldXml";
addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath };
Testing.AssertThrows<FileNotFoundException>(() => addWebCmdlet.ExecuteCmdlet());
}
}
示例6: AddAzureWebRoleWithTemplateFolder
public void AddAzureWebRoleWithTemplateFolder()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string roleName = "WebRole1";
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
string originalDirectory = Directory.GetCurrentDirectory();
string scaffoldingPath = "MyWebTemplateFolder";
Directory.SetCurrentDirectory(rootPath);
addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath };
addWebCmdlet.ExecuteCmdlet();
AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), scaffoldingPath);
Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
Directory.SetCurrentDirectory(originalDirectory);
}
}
示例7: EnableAzureMemcacheRoleProcessAlreadyEnabledFail
public void EnableAzureMemcacheRoleProcessAlreadyEnabledFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string cacheRoleName = "WorkerRole";
string webRoleName = "WebRole";
string expected = string.Format(Resources.CacheAlreadyEnabledMessage, webRoleName);
addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName };
addNodeWebCmdlet.ExecuteCmdlet();
addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath);
Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath));
}
}
示例8: EnableAzureMemcacheWithNoCacheWorkerRolesFail
public void EnableAzureMemcacheWithNoCacheWorkerRolesFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string webRoleName = "WebRole";
string expectedMessage = string.Format(Resources.NoCacheWorkerRoles);
addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName };
addNodeWebCmdlet.ExecuteCmdlet();
addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" };
addNodeWorkerCmdlet.ExecuteCmdlet();
mockCommandRuntime.ResetPipelines();
enableCacheCmdlet.PassThru = true;
enableCacheCmdlet.CacheRuntimeVersion = "1.8.0";
Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, null, rootPath), expectedMessage);
}
}
示例9: EnableAzureMemcacheRoleProcessRoleDoesNotExistFail
public void EnableAzureMemcacheRoleProcessRoleDoesNotExistFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string cacheRoleName = "WorkerRole";
string webRoleName = "WebRole";
string expected = string.Format(Resources.RoleNotFoundMessage, webRoleName);
addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath));
}
}
示例10: EnableAzureMemcacheRoleProcessOnWorkerRoleSuccess
public void EnableAzureMemcacheRoleProcessOnWorkerRoleSuccess()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string serviceName = "AzureService";
string rootPath = files.CreateNewService(serviceName);
string cacheRoleName = "CacheWorkerRole";
string workerRoleName = "WorkerRole";
string expectedMessage = string.Format(Resources.EnableMemcacheMessage, workerRoleName, cacheRoleName, Resources.MemcacheEndpointPort);
addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = workerRoleName };
addNodeWorkerCmdlet.ExecuteCmdlet();
addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
mockCommandRuntime.ResetPipelines();
enableCacheCmdlet.PassThru = true;
enableCacheCmdlet.EnableAzureMemcacheRoleProcess(workerRoleName, cacheRoleName, rootPath);
WorkerRole workerRole = CloudServiceTesting.GetWorkerRole(rootPath, workerRoleName);
AzureAssert.RuntimeUrlAndIdExists(workerRole.Startup.Task, Resources.CacheRuntimeValue);
AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, serviceName, workerRoleName), Path.Combine(Resources.CacheScaffolding, Resources.WorkerRole));
AzureAssert.StartupTaskExists(workerRole.Startup.Task, Resources.CacheStartupCommand);
AzureAssert.InternalEndpointExists(workerRole.Endpoints.InternalEndpoint,
new InternalEndpoint { name = Resources.MemcacheEndpointName, protocol = InternalProtocol.tcp, port = Resources.MemcacheEndpointPort });
LocalStore localStore = new LocalStore
{
name = Resources.CacheDiagnosticStoreName,
cleanOnRoleRecycle = false
};
AzureAssert.LocalResourcesLocalStoreExists(localStore, workerRole.LocalResources);
DefConfigurationSetting diagnosticLevel = new DefConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName };
AzureAssert.ConfigurationSettingExist(diagnosticLevel, workerRole.ConfigurationSettings);
ConfigConfigurationSetting clientDiagnosticLevel = new ConfigConfigurationSetting { name = Resources.ClientDiagnosticLevelName, value = Resources.ClientDiagnosticLevelValue };
AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, CloudServiceTesting.GetCloudRole(rootPath, workerRoleName).ConfigurationSettings);
AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, CloudServiceTesting.GetLocalRole(rootPath, workerRoleName).ConfigurationSettings);
string workerConfigPath = string.Format(@"{0}\{1}\{2}", rootPath, workerRoleName, "web.config");
string workerCloudConfig = File.ReadAllText(workerConfigPath);
Assert.IsTrue(workerCloudConfig.Contains("configSections"));
Assert.IsTrue(workerCloudConfig.Contains("dataCacheClients"));
Assert.AreEqual<string>(expectedMessage, mockCommandRuntime.VerboseStream[0]);
Assert.AreEqual<string>(workerRoleName, (mockCommandRuntime.OutputPipeline[0] as PSObject).GetVariableValue<string>(Parameters.RoleName));
}
}