本文整理汇总了C#中MockCommandRuntime类的典型用法代码示例。如果您正苦于以下问题:C# MockCommandRuntime类的具体用法?C# MockCommandRuntime怎么用?C# MockCommandRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockCommandRuntime类属于命名空间,在下文中一共展示了MockCommandRuntime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProfileCmdletTests
public ProfileCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
}
示例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));
}
}
示例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();
}
示例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);
}
}
}
示例5: NewAzureServiceTests
public NewAzureServiceTests()
{
cmdlet = new NewAzureServiceProjectCommand();
mockCommandRuntime = new MockCommandRuntime();
cmdlet.CommandRuntime = mockCommandRuntime;
TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
}
示例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);
}
}
示例7: TestSetup
public void TestSetup()
{
mockCommandRuntime = new MockCommandRuntime();
cmdlet = new SetAzureServiceProjectRoleCommand();
cmdlet.CommandRuntime = mockCommandRuntime;
cmdlet.PassThru = true;
}
示例8: TenantCmdletTests
public TenantCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureRmProfileProvider.Instance.Profile = new AzureRMProfile();
}
示例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);
}
示例10: SetAzureInstancesTests
public SetAzureInstancesTests()
{
mockCommandRuntime = new MockCommandRuntime();
cmdlet = new SetAzureServiceProjectRoleCommand();
cmdlet.CommandRuntime = mockCommandRuntime;
cmdlet.PassThru = true;
}
示例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);
}
示例12: ContextCmdletTests
public ContextCmdletTests(ITestOutputHelper output)
{
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
}
示例13: InitCommand
public void InitCommand()
{
MockCmdRunTime = new MockCommandRuntime();
command = new StorageCloudCmdletBase<IStorageManagement>
{
CommandRuntime = MockCmdRunTime
};
}
示例14: DisableAzureRemoteDesktopCommandTest
public DisableAzureRemoteDesktopCommandTest()
{
AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
disableRDCmdlet = new DisableAzureServiceProjectRemoteDesktopCommand();
disableRDCmdlet.CommandRuntime = mockCommandRuntime;
}
示例15: SetupTest
public void SetupTest()
{
GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
mockCommandRuntime = new MockCommandRuntime();
disableRDCmdlet = new DisableAzureServiceProjectRemoteDesktopCommand();
disableRDCmdlet.CommandRuntime = mockCommandRuntime;
}