本文整理汇总了C#中Microsoft.WindowsAzure.Management.Test.Utilities.Common.FileSystemHelper类的典型用法代码示例。如果您正苦于以下问题:C# FileSystemHelper类的具体用法?C# FileSystemHelper怎么用?C# FileSystemHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystemHelper类属于Microsoft.WindowsAzure.Management.Test.Utilities.Common命名空间,在下文中一共展示了FileSystemHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCreateStorageServiceWithPublish
public void TestCreateStorageServiceWithPublish()
{
using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cloudService.Deployments.Add(deployment);
serviceManagementChannelMock.Setup(f => f.EndGetStorageService(It.IsAny<IAsyncResult>()))
.Callback(() => serviceManagementChannelMock.Setup(f => f.EndGetStorageService(
It.IsAny<IAsyncResult>()))
.Returns(storageService))
.Throws(new EndpointNotFoundException());
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US"));
serviceManagementChannelMock.Verify(f => f.BeginCreateStorageService(
subscription.SubscriptionId,
It.IsAny<CreateStorageServiceInput>(),
null,
null), Times.Once());
}
}
示例2: SetDeploymentStatusProcessDeploymentDoesNotExistTest
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest()
{
SimpleServiceManagement channel = new SimpleServiceManagement();
string newStatus = DeploymentStatus.Running;
string resultMessage;
string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, slot, serviceName);
bool statusUpdated = false;
channel.UpdateDeploymentStatusBySlotThunk = ar =>
{
statusUpdated = true;
channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus};
};
channel.GetDeploymentBySlotThunk = ar => { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); };
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
deploymentManager.CommandRuntime = new MockCommandRuntime();
deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0];
Assert.IsFalse(statusUpdated);
Assert.IsTrue(resultMessage.Contains(expectedMessage));
Assert.IsTrue(((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline.Count.Equals(0));
}
}
示例3: AddNewCacheWorkerRoleSuccessful
public void AddNewCacheWorkerRoleSuccessful()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string rootPath = Path.Combine(files.RootPath, "AzureService");
string roleName = "WorkerRole";
int expectedInstanceCount = 10;
newServiceCmdlet.NewAzureServiceProcess(files.RootPath, "AzureService");
WorkerRole cacheWorkerRole = addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(roleName, expectedInstanceCount, rootPath);
AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", "WorkerRole"), Path.Combine(Resources.GeneralScaffolding, Resources.WorkerRole));
AzureAssert.WorkerRoleImportsExists(new Import { moduleName = Resources.CachingModuleName }, cacheWorkerRole);
AzureAssert.LocalResourcesLocalStoreExists(new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false },
cacheWorkerRole.LocalResources);
Assert.IsNull(cacheWorkerRole.Endpoints.InputEndpoint);
AssertConfigExists(Testing.GetCloudRole(rootPath, roleName));
AssertConfigExists(Testing.GetLocalRole(rootPath, roleName), Resources.EmulatorConnectionString);
PSObject actualOutput = mockCommandRuntime.OutputPipeline[1] as PSObject;
Assert.AreEqual<string>(roleName, actualOutput.Members[Parameters.CacheWorkerRoleName].Value.ToString());
Assert.AreEqual<int>(expectedInstanceCount, int.Parse(actualOutput.Members[Parameters.Instances].Value.ToString()));
}
}
示例4: SetAzureServiceProjectTestsLocationValid
public void SetAzureServiceProjectTestsLocationValid()
{
string[] locations = { "West US", "East US", "East Asia", "North Europe" };
foreach (string item in locations)
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
// Create new empty settings file
//
ServicePathInfo paths = new ServicePathInfo(files.RootPath);
ServiceSettings settings = new ServiceSettings();
mockCommandRuntime = new MockCommandRuntime();
setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
settings.Save(paths.Settings);
settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item, null, null, null, paths.Settings);
// Assert location is changed
//
Assert.AreEqual<string>(item, settings.Location);
ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
Assert.AreEqual<string>(item, settings.Location);
}
}
}
示例5: RemoveAzureServiceProcessTest
public void RemoveAzureServiceProcessTest()
{
bool serviceDeleted = false;
bool deploymentDeleted = false;
channel.GetDeploymentBySlotThunk = ar =>
{
if (deploymentDeleted) throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty);
return new Deployment{Name = serviceName, DeploymentSlot = ArgumentConstants.Slots[SlotType.Production], Status = DeploymentStatus.Suspended};
};
channel.DeleteHostedServiceThunk = ar => serviceDeleted = true;
channel.DeleteDeploymentBySlotThunk = ar =>
{
deploymentDeleted = true;
};
channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false };
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
removeServiceCmdlet.PassThru = true;
removeServiceCmdlet.RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty, serviceName);
Assert.IsTrue(deploymentDeleted);
Assert.IsTrue(serviceDeleted);
Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]);
}
}
示例6: 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);
}
}
示例7: SetAzureInstancesProcessTestsEmptyRoleNameFail
public void SetAzureInstancesProcessTestsEmptyRoleNameFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, string.Empty, 10), string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.RoleName));
}
}
示例8: DisableRemoteDesktopForEmptyService
public void DisableRemoteDesktopForEmptyService()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
files.CreateNewService("NEW_SERVICE");
disableRDCmdlet.DisableRemoteDesktop();
}
}
示例9: SetAzureInstancesProcessNegativeRoleInstanceFail
public void SetAzureInstancesProcessNegativeRoleInstanceFail()
{
string roleName = "WebRole1";
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, roleName, -1), string.Format(Resources.InvalidInstancesCount, roleName));
}
}
示例10: SetAzureVMSizeProcessNegativeRoleInstanceFail
public void SetAzureVMSizeProcessNegativeRoleInstanceFail()
{
string roleName = "WebRole1";
using (FileSystemHelper files = new FileSystemHelper(this))
{
AzureService service = new AzureService(files.RootPath, serviceName, null);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleVMSize(service.Paths, roleName, string.Empty), string.Format(Resources.InvalidVMSize, roleName));
}
}
示例11: GetNextPortAllNull
public void GetNextPortAllNull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultWebPort);
AzureService service = new AzureService(files.RootPath, serviceName, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例12: NewAzureServiceWithInvalidNames
public void NewAzureServiceWithInvalidNames()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
foreach (string name in Data.InvalidServiceNames)
{
cmdlet.ServiceName = name;
Testing.AssertThrows<ArgumentException>(() => cmdlet.ExecuteCmdlet());
}
}
}
示例13: GetNextPortNodeWorkerRoleNull
public void GetNextPortNodeWorkerRoleNull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
AzureService service = new AzureService(files.RootPath, serviceName, null);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service = new AzureService(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例14: SetAzureServiceProjectTestsLocationEmptyFail
public void SetAzureServiceProjectTestsLocationEmptyFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
// Create new empty settings file
//
ServicePathInfo paths = new ServicePathInfo(files.RootPath);
ServiceSettings settings = new ServiceSettings();
settings.Save(paths.Settings);
Testing.AssertThrows<ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(string.Empty, null, null, null, paths.Settings), string.Format(Resources.InvalidOrEmptyArgumentMessage, "Location"));
}
}
示例15: CreateLocalPackageWithNodeWorkerRoleTest
public void CreateLocalPackageWithNodeWorkerRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string standardOutput;
string standardError;
AzureService service = new AzureService(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
}
}