当前位置: 首页>>代码示例>>C#>>正文


C# MockCommandRuntime类代码示例

本文整理汇总了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();
 }
开发者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


注:本文中的MockCommandRuntime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。