本文整理汇总了C#中MockCommandRuntime类的典型用法代码示例。如果您正苦于以下问题:C# MockCommandRuntime类的具体用法?C# MockCommandRuntime怎么用?C# MockCommandRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockCommandRuntime类属于命名空间,在下文中一共展示了MockCommandRuntime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ProfileCmdletTests
public ProfileCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:7,代码来源:ProfileCmdletTests.cs
示例2: GetAzureSBLocationSuccessfull
public void GetAzureSBLocationSuccessfull()
{
// Setup
Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
string name = "test";
GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand()
{
CommandRuntime = mockCommandRuntime,
Client = client.Object
};
List<ServiceBusLocation> expected = new List<ServiceBusLocation>();
expected.Add(new ServiceBusLocation { Code = name, FullName = name });
client.Setup(f => f.GetServiceBusRegions()).Returns(expected);
// Test
cmdlet.ExecuteCmdlet();
// Assert
IEnumerable<ServiceBusLocation> actual =
System.Management.Automation.LanguagePrimitives.GetEnumerable(mockCommandRuntime.OutputPipeline).Cast<ServiceBusLocation>();
Assert.Equal<int>(expected.Count, actual.Count());
for (int i = 0; i < expected.Count; i++)
{
Assert.True(actual.Any((account) => account.Code == expected[i].Code));
Assert.True(actual.Any((account) => account.FullName == expected[i].FullName));
}
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:30,代码来源:GetAzureSBLocationTest.cs
示例3: EnableRemoteDesktop
/// <summary>
/// Invoke the Enable-AzureServiceProjectRemoteDesktop enableRDCmdlet.
/// </summary>
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
public static void EnableRemoteDesktop(string username, string password)
{
SecureString securePassword = null;
if (password != null)
{
securePassword = new SecureString();
foreach (char ch in password)
{
securePassword.AppendChar(ch);
}
securePassword.MakeReadOnly();
}
if (enableRDCmdlet == null)
{
enableRDCmdlet = new EnableAzureServiceProjectRemoteDesktopCommand();
if (mockCommandRuntime == null)
{
mockCommandRuntime = new MockCommandRuntime();
}
enableRDCmdlet.CommandRuntime = mockCommandRuntime;
}
enableRDCmdlet.Username = username;
enableRDCmdlet.Password = securePassword;
enableRDCmdlet.EnableRemoteDesktop();
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:32,代码来源:EnableAzureRemoteDesktopCommandTest.cs
示例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
//
PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
ServiceSettings settings = new ServiceSettings();
mockCommandRuntime = new MockCommandRuntime();
setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
settings.Save(paths.Settings);
settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item, 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);
}
}
}
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:25,代码来源:SetAzureServiceProjectTests.cs
示例5: NewAzureServiceTests
public NewAzureServiceTests()
{
cmdlet = new NewAzureServiceProjectCommand();
mockCommandRuntime = new MockCommandRuntime();
cmdlet.CommandRuntime = mockCommandRuntime;
TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
}
开发者ID:Azure,项目名称:azure-powershell,代码行数:7,代码来源:NewAzureServiceTests.cs
示例6: GetAzureSBLocationSuccessfull
public void GetAzureSBLocationSuccessfull()
{
// Setup
Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
string name = "test";
GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand()
{
CommandRuntime = mockCommandRuntime,
Client = client.Object
};
List<ServiceBusLocation> expected = new List<ServiceBusLocation>();
expected.Add(new ServiceBusLocation { Code = name, FullName = name });
client.Setup(f => f.GetServiceBusRegions()).Returns(expected);
// Test
cmdlet.ExecuteCmdlet();
// Assert
List<ServiceBusLocation> actual = mockCommandRuntime.OutputPipeline[0] as List<ServiceBusLocation>;
Assert.AreEqual<int>(expected.Count, actual.Count);
for (int i = 0; i < expected.Count; i++)
{
Assert.AreEqual<string>(expected[i].Code, actual[i].Code);
Assert.AreEqual<string>(expected[i].FullName, actual[i].FullName);
}
}
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:28,代码来源:GetAzureSBLocationTest.cs
示例7: TestSetup
public void TestSetup()
{
mockCommandRuntime = new MockCommandRuntime();
cmdlet = new SetAzureServiceProjectRoleCommand();
cmdlet.CommandRuntime = mockCommandRuntime;
cmdlet.PassThru = true;
}
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:7,代码来源:SetAzureVMSizeTests.cs
示例8: TenantCmdletTests
public TenantCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureRmProfileProvider.Instance.Profile = new AzureRMProfile();
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:7,代码来源:TenantCmdletTests.cs
示例9: GetAzureSqlDatabaseServerFirewallRuleProcessTest
public void GetAzureSqlDatabaseServerFirewallRuleProcessTest()
{
SqlDatabaseFirewallRulesList firewallList = new SqlDatabaseFirewallRulesList();
MockCommandRuntime commandRuntime = new MockCommandRuntime();
SimpleSqlDatabaseManagement channel = new SimpleSqlDatabaseManagement();
channel.NewServerFirewallRuleThunk = ar =>
{
Assert.AreEqual("Server1", (string)ar.Values["serverName"]);
SqlDatabaseFirewallRule newRule = new SqlDatabaseFirewallRule();
newRule.Name = ((SqlDatabaseFirewallRuleInput)ar.Values["input"]).Name;
newRule.StartIPAddress = ((SqlDatabaseFirewallRuleInput)ar.Values["input"]).StartIPAddress;
newRule.EndIPAddress = ((SqlDatabaseFirewallRuleInput)ar.Values["input"]).EndIPAddress;
firewallList.Add(newRule);
};
channel.GetServerFirewallRulesThunk = ar =>
{
return firewallList;
};
// New firewall rule with IpRange parameter set
NewAzureSqlDatabaseServerFirewallRule newAzureSqlDatabaseServerFirewallRule = new NewAzureSqlDatabaseServerFirewallRule(channel) { ShareChannel = true };
newAzureSqlDatabaseServerFirewallRule.CurrentSubscription = UnitTestHelpers.CreateUnitTestSubscription();
newAzureSqlDatabaseServerFirewallRule.CommandRuntime = commandRuntime;
var newFirewallResult = newAzureSqlDatabaseServerFirewallRule.NewAzureSqlDatabaseServerFirewallRuleProcess("IpRange", "Server1", "Rule1", "0.0.0.0", "1.1.1.1");
Assert.AreEqual("Success", newFirewallResult.OperationStatus);
newFirewallResult = newAzureSqlDatabaseServerFirewallRule.NewAzureSqlDatabaseServerFirewallRuleProcess("IpRange", "Server1", "Rule2", "1.1.1.1", "2.2.2.2");
Assert.AreEqual("Success", newFirewallResult.OperationStatus);
// Get all rules
GetAzureSqlDatabaseServerFirewallRule getAzureSqlDatabaseServerFirewallRule = new GetAzureSqlDatabaseServerFirewallRule(channel) { ShareChannel = true };
getAzureSqlDatabaseServerFirewallRule.CurrentSubscription = UnitTestHelpers.CreateUnitTestSubscription();
getAzureSqlDatabaseServerFirewallRule.CommandRuntime = commandRuntime;
var getFirewallResult = getAzureSqlDatabaseServerFirewallRule.GetAzureSqlDatabaseServerFirewallRuleProcess("Server1", null);
Assert.AreEqual(2, getFirewallResult.Count());
var firstRule = getFirewallResult.First();
Assert.AreEqual("Server1", firstRule.ServerName);
Assert.AreEqual("Rule1", firstRule.RuleName);
Assert.AreEqual("0.0.0.0", firstRule.StartIpAddress);
Assert.AreEqual("1.1.1.1", firstRule.EndIpAddress);
Assert.AreEqual("Success", firstRule.OperationStatus);
var lastRule = getFirewallResult.Last();
Assert.AreEqual("Server1", lastRule.ServerName);
Assert.AreEqual("Rule2", lastRule.RuleName);
Assert.AreEqual("1.1.1.1", lastRule.StartIpAddress);
Assert.AreEqual("2.2.2.2", lastRule.EndIpAddress);
Assert.AreEqual("Success", lastRule.OperationStatus);
// Get one rule
getFirewallResult = getAzureSqlDatabaseServerFirewallRule.GetAzureSqlDatabaseServerFirewallRuleProcess("Server1", "Rule2");
Assert.AreEqual(1, getFirewallResult.Count());
firstRule = getFirewallResult.First();
Assert.AreEqual("Server1", firstRule.ServerName);
Assert.AreEqual("Rule2", firstRule.RuleName);
Assert.AreEqual("1.1.1.1", firstRule.StartIpAddress);
Assert.AreEqual("2.2.2.2", firstRule.EndIpAddress);
Assert.AreEqual("Success", firstRule.OperationStatus);
Assert.AreEqual(0, commandRuntime.ErrorRecords.Count);
}
开发者ID:vijayrvr,项目名称:azure-sdk-tools,代码行数:60,代码来源:FirewallCmdletTests.cs
示例10: SetAzureInstancesTests
public SetAzureInstancesTests()
{
mockCommandRuntime = new MockCommandRuntime();
cmdlet = new SetAzureServiceProjectRoleCommand();
cmdlet.CommandRuntime = mockCommandRuntime;
cmdlet.PassThru = true;
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:7,代码来源:SetAzureInstancesTests.cs
示例11: NewAzureSBNamespaceSuccessfull
public void NewAzureSBNamespaceSuccessfull()
{
// Setup
MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
string name = "test";
string location = "West US";
NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
{
Name = name,
Location = location,
CommandRuntime = mockCommandRuntime,
Client = client.Object
};
ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name, Region = location };
client.Setup(f => f.CreateNamespace(name, location)).Returns(expected);
client.Setup(f => f.GetServiceBusRegions()).Returns(new List<ServiceBusLocation>()
{
new ServiceBusLocation () { Code = location }
});
// Test
cmdlet.ExecuteCmdlet();
// Assert
ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;
Assert.AreEqual<ExtendedServiceBusNamespace>(expected, actual);
}
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:28,代码来源:NewAzureSBNamespaceTest.cs
示例12: ContextCmdletTests
public ContextCmdletTests(ITestOutputHelper output)
{
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
}
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:8,代码来源:ContextCmdletTests.cs
示例13: InitCommand
public void InitCommand()
{
MockCmdRunTime = new MockCommandRuntime();
command = new StorageCloudCmdletBase<IStorageManagement>
{
CommandRuntime = MockCmdRunTime
};
}
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:8,代码来源:StorageCloudCmdletBaseTest.cs
示例14: DisableAzureRemoteDesktopCommandTest
public DisableAzureRemoteDesktopCommandTest()
{
AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
disableRDCmdlet = new DisableAzureServiceProjectRemoteDesktopCommand();
disableRDCmdlet.CommandRuntime = mockCommandRuntime;
}
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:8,代码来源:DisableAzureRemoteDesktopCommandTest.cs
示例15: SetupTest
public void SetupTest()
{
GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
disableRDCmdlet = new DisableAzureServiceProjectRemoteDesktopCommand();
disableRDCmdlet.CommandRuntime = mockCommandRuntime;
}
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:8,代码来源:DisableAzureRemoteDesktopCommandTest.cs
示例16: GetAzureDedicatedCircuitSuccessful
public void GetAzureDedicatedCircuitSuccessful()
{
// Setup
string circuitName = "TestCircuit";
uint bandwidth = 10;
string serviceProviderName = "TestProvider";
string location = "us-west";
string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead";
BillingType billingType = BillingType.MeteredData;
MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient();
var dcMock = new Mock<IDedicatedCircuitOperations>();
DedicatedCircuitGetResponse expected =
new DedicatedCircuitGetResponse()
{
DedicatedCircuit = new AzureDedicatedCircuit()
{
CircuitName = circuitName,
Bandwidth = bandwidth,
BillingType = billingType.ToString(),
Location = location,
ServiceProviderName = serviceProviderName,
ServiceKey = serviceKey,
ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned,
Status = DedicatedCircuitState.Enabled,
},
RequestId = "",
StatusCode = new HttpStatusCode()
};
var t = new Task<DedicatedCircuitGetResponse>(() => expected);
t.Start();
dcMock.Setup(f => f.GetAsync(It.Is<string>(sKey => sKey == serviceKey), It.IsAny<CancellationToken>())).Returns((string sKey, CancellationToken cancellation) => t);
client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object);
GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand()
{
ServiceKey = Guid.Parse(serviceKey),
CommandRuntime = mockCommandRuntime,
ExpressRouteClient = new ExpressRouteClient(client.Object)
};
cmdlet.ExecuteCmdlet();
// Assert
AzureDedicatedCircuit actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit;
Assert.Equal<string>(expected.DedicatedCircuit.BillingType, actual.BillingType);
Assert.Equal<string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName);
Assert.Equal<uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth);
Assert.Equal<string>(expected.DedicatedCircuit.Location, actual.Location);
Assert.Equal<string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName);
Assert.Equal(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState);
Assert.Equal(expected.DedicatedCircuit.Status, actual.Status);
Assert.Equal<string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey);
}
开发者ID:takekazuomi,项目名称:azure-powershell,代码行数:58,代码来源:AzureDedicatedCircuitTests.cs
示例17: SetAzureServiceProjectTests
public SetAzureServiceProjectTests()
{
AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
setServiceProjectCmdlet = new SetAzureServiceProjectCommand();
setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
setServiceProjectCmdlet.PassThru = true;
}
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:9,代码来源:SetAzureServiceProjectTests.cs
示例18: SetupTest
public void SetupTest()
{
GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
setServiceProjectCmdlet = new SetAzureServiceProjectCommand();
setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
setServiceProjectCmdlet.PassThru = true;
}
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:9,代码来源:SetAzureServiceProjectTests.cs
示例19: SetupTest
public void SetupTest()
{
GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
enableCacheCmdlet = new EnableAzureMemcacheRoleCommand();
addCacheRoleCmdlet = new AddAzureCacheWorkerRoleCommand();
addCacheRoleCmdlet.CommandRuntime = mockCommandRuntime;
enableCacheCmdlet.CommandRuntime = mockCommandRuntime;
}
开发者ID:B-Rich,项目名称:azure-sdk-tools,代码行数:10,代码来源:EnableAzureMemcacheRoleTests.cs
示例20: SetupTest
//[TestInitialize]
public void SetupTest()
{
// CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();
deploymentUrl = AnyUrl();
roleName = AnyString();
publicPort = AnyIpPort();
secondRolesPublicPort = AnyIpPort();
mockCommandRuntime = new MockCommandRuntime();
}
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:11,代码来源:GetAzureWinRMUriTests.cs
注:本文中的MockCommandRuntime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论