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


C# Common.MockCommandRuntime类代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Management.Test.Utilities.Common.MockCommandRuntime的典型用法代码示例。如果您正苦于以下问题:C# MockCommandRuntime类的具体用法?C# MockCommandRuntime怎么用?C# MockCommandRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MockCommandRuntime类属于Microsoft.WindowsAzure.Management.Test.Utilities.Common命名空间,在下文中一共展示了MockCommandRuntime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestImportPublishSettingsWithMultiplePublishSettingsFilesFound

        public void TestImportPublishSettingsWithMultiplePublishSettingsFilesFound()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            string directoryName = "testdir2";
            string fileName1 = "myfile1.publishsettings";
            string fileName2 = "myfile2.publishsettings";
            string filePath1 = Path.Combine(directoryName, fileName1);
            string filePath2 = Path.Combine(directoryName, fileName2);
            Directory.CreateDirectory(directoryName);
            File.WriteAllText(filePath1, File.ReadAllText(Data.ValidPublishSettings.First()));
            File.WriteAllText(filePath2, File.ReadAllText(Data.ValidPublishSettings.First()));
            cmdlet.PublishSettingsFile = directoryName;

            cmdlet.ExecuteCmdlet();

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);
            Assert.AreEqual<string>(filePath1, mockCommandRuntime.OutputPipeline[0].ToString());
            Assert.AreEqual<string>(string.Format(Resources.MultiplePublishSettingsFilesFoundMessage, filePath1), mockCommandRuntime.WarningStream[0]);
        }
开发者ID:redwater,项目名称:azure-sdk-tools,代码行数:26,代码来源:ImportAzurePublishSettingsTest.cs

示例2: CreatesNewSBCaseInsensitiveRegion

        public void CreatesNewSBCaseInsensitiveRegion()
        {
            // Setup
            SimpleServiceBusManagement channel = new SimpleServiceBusManagement();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            string location = "West US";
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand(channel)
            {
                Name = name,
                Location = "west Us",
                CommandRuntime = mockCommandRuntime
            };
            ServiceBusNamespace expected = new ServiceBusNamespace { Name = name, Region = location };
            channel.CreateServiceBusNamespaceThunk = csbn => { return expected; };
            channel.ListServiceBusRegionsThunk = lsbr =>
            {
                List<ServiceBusRegion> list = new List<ServiceBusRegion>();
                list.Add(new ServiceBusRegion { Code = location });
                return list;
            };

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ServiceBusNamespace;
            Assert.AreEqual<ServiceBusNamespace>(expected, actual);
        }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:29,代码来源:NewAzureSBNamespaceTest.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:xmbms,项目名称:azure-sdk-tools,代码行数:32,代码来源:EnableAzureRemoteDesktopCommandTest.cs

示例4: 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 = UnitTestHelper.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 = UnitTestHelper.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.ErrorStream.Count);
        }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:60,代码来源:FirewallCmdletTests.cs

示例5: 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);
                }
            }
        }
开发者ID:Viachaslau,项目名称:azure-sdk-tools,代码行数:25,代码来源:SetAzureServiceProjectTests.cs

示例6: SetupTest

 public void SetupTest()
 {
     channel = new SimpleServiceManagement();
     serviceBusChannel = new SimpleServiceBusManagement();
     mockCommandRuntime = new MockCommandRuntime();
     cmdlet = new TestAzureNameCommand(channel, serviceBusChannel) { CommandRuntime = mockCommandRuntime };
     CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();
 }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:8,代码来源:TestAzureNameTests.cs

示例7: ProcessNewWebsiteTest

        public void ProcessNewWebsiteTest()
        {
            const string websiteName = "website1";
            const string webspaceName = "webspace1";

            // Setup
            bool created = true;
            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();
            channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace>
            {
                new WebSpace { Name = "webspace1", GeoRegion = "webspace1" },
                new WebSpace { Name = "webspace2", GeoRegion = "webspace2" }
            });

            channel.GetSiteConfigThunk = ar =>
            {
                if (ar.Values["name"].Equals("website1") && ar.Values["webspaceName"].Equals("webspace1"))
                {
                    return new SiteConfig
                    {
                        PublishingUsername = "user1"
                    };
                }

                return null;
            };

            channel.CreateSiteThunk = ar =>
                                          {
                                              Assert.AreEqual(webspaceName, ar.Values["webspaceName"]);
                                              Site website = ar.Values["site"] as Site;
                                              Assert.IsNotNull(website);
                                              Assert.AreEqual(websiteName, website.Name);
                                              Assert.IsNotNull(website.HostNames.FirstOrDefault(hostname => hostname.Equals(websiteName + General.AzureWebsiteHostNameSuffix)));
                                              created = true;
                                              return website;
                                          };

            // Test
            MockCommandRuntime mockRuntime = new MockCommandRuntime();
            NewAzureWebsiteCommand newAzureWebsiteCommand = new NewAzureWebsiteCommand(channel)
            {
                ShareChannel = true,
                CommandRuntime = mockRuntime,
                Name = websiteName,
                Location = webspaceName,
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }
            };

            newAzureWebsiteCommand.ExecuteCmdlet();
            Assert.IsTrue(created);
            Assert.AreEqual<string>(websiteName, (mockRuntime.OutputPipeline[0] as SiteWithConfig).Name);
        }
开发者ID:johnkors,项目名称:azure-sdk-tools,代码行数:53,代码来源:NewAzureWebSiteTests.cs

示例8: SetupTest

        public void SetupTest()
        {
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();
            mockCommandRuntime = new MockCommandRuntime();
            cloudServiceClientMock = new Mock<ICloudServiceClient>();

            stopServiceCmdlet = new StopAzureServiceCommand()
            {
                CloudServiceClient = cloudServiceClientMock.Object,
                CommandRuntime = mockCommandRuntime
            };
        }
开发者ID:TanaryTai,项目名称:azure-sdk-tools,代码行数:13,代码来源:StopAzureServiceTests.cs

示例9: GetAzureSBNamespaceWithInvalidNamesFail

        public void GetAzureSBNamespaceWithInvalidNamesFail()
        {
            // Setup
            string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" };

            foreach (string invalidName in invalidNames)
            {
                MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
                GetAzureSBNamespaceCommand cmdlet = new GetAzureSBNamespaceCommand() { Name = invalidName, CommandRuntime = mockCommandRuntime };
                string expected = string.Format("{0}\r\nParameter name: Name", string.Format(Resources.InvalidNamespaceName, invalidName));

                Testing.AssertThrows<ArgumentException>(() => cmdlet.ExecuteCmdlet(), expected);
            }
        }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:14,代码来源:GetAzureSBNamespaceTest.cs

示例10: SetupTest

        public void SetupTest()
        {
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();
            mockCommandRuntime = new MockCommandRuntime();

            addNodeWebCmdlet = new AddAzureNodeWebRoleCommand();
            addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand();
            cmdlet = new SaveAzureServiceProjectPackageCommand();

            addNodeWorkerCmdlet.CommandRuntime = mockCommandRuntime;
            addNodeWebCmdlet.CommandRuntime = mockCommandRuntime;
            cmdlet.CommandRuntime = mockCommandRuntime;
        }
开发者ID:johnkors,项目名称:azure-sdk-tools,代码行数:14,代码来源:SaveAzureServiceProjectPackageTests.cs

示例11: GetsWebsiteDefaultLocation

        public void GetsWebsiteDefaultLocation()
        {
            const string websiteName = "website1";
            const string suffix = "azurewebsites.com";
            const string location = "West US";

            // Setup
            Mock<IWebsitesClient> clientMock = new Mock<IWebsitesClient>();
            clientMock.Setup(f => f.GetWebsiteDnsSuffix()).Returns(suffix);
            clientMock.Setup(f => f.GetDefaultLocation()).Returns(location);
            bool created = true;
            SimpleWebsitesManagement channel = new SimpleWebsitesManagement();
            channel.GetWebSpacesThunk = ar => new WebSpaces();

            channel.GetSiteConfigThunk = ar =>
            {
                return new SiteConfig
                {
                    PublishingUsername = "user1"
                };
            };

            channel.CreateSiteThunk = ar =>
            {
                Site website = ar.Values["site"] as Site;
                Assert.IsNotNull(website);
                Assert.AreEqual(websiteName, website.Name);
                Assert.IsNotNull(website.HostNames.FirstOrDefault(hostname => hostname.Equals(string.Format("{0}.{1}", websiteName, suffix))));
                created = true;
                return website;
            };

            // Test
            MockCommandRuntime mockRuntime = new MockCommandRuntime();
            NewAzureWebsiteCommand newAzureWebsiteCommand = new NewAzureWebsiteCommand(channel)
            {
                ShareChannel = true,
                CommandRuntime = mockRuntime,
                Name = websiteName,
                CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionId },
                WebsitesClient = clientMock.Object
            };

            newAzureWebsiteCommand.ExecuteCmdlet();
            Assert.IsTrue(created);
            Assert.AreEqual<string>(websiteName, (mockRuntime.OutputPipeline[0] as SiteWithConfig).Name);
            clientMock.Verify(f => f.GetDefaultLocation(), Times.Once());
        }
开发者ID:TanaryTai,项目名称:azure-sdk-tools,代码行数:48,代码来源:NewAzureWebSiteTests.cs

示例12: RemoveAzureSBNamespaceWithInternalServerError

        public void RemoveAzureSBNamespaceWithInternalServerError()
        {
            // Setup
            SimpleServiceBusManagement channel = new SimpleServiceBusManagement();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, CommandRuntime = mockCommandRuntime };
            string expected = Resources.RemoveNamespaceErrorMessage;
            channel.DeleteServiceBusNamespaceThunk = dsbn => { throw new Exception(Resources.InternalServerErrorMessage); };

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ErrorRecord actual = mockCommandRuntime.ErrorStream[0];
            Assert.AreEqual<string>(expected, actual.Exception.Message);
        }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:17,代码来源:RemoveAzureSBNamespaceTest.cs

示例13: RemoveAzureSBNamespaceSuccessfull

        public void RemoveAzureSBNamespaceSuccessfull()
        {
            // Setup
            SimpleServiceBusManagement channel = new SimpleServiceBusManagement();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, CommandRuntime = mockCommandRuntime, PassThru = true };
            bool deleted = false;
            channel.DeleteServiceBusNamespaceThunk = dsbn => { deleted = true; };

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            Assert.IsTrue(deleted);
            Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]);
        }
开发者ID:xmbms,项目名称:azure-sdk-tools,代码行数:17,代码来源:RemoveAzureSBNamespaceTest.cs

示例14: AddAzurePHPWorkerRoleProcess

        public void AddAzurePHPWorkerRoleProcess()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName = "WorkerRole1";
                string serviceName = "AzureService";
                string rootPath = files.CreateNewService(serviceName);
                mockCommandRuntime = new MockCommandRuntime();
                addPHPWorkerCmdlet = new AddAzurePHPWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime };
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePHP, rootPath, roleName);

                addPHPWorkerCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole));
                Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
                Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
            }
        }
开发者ID:johnkors,项目名称:azure-sdk-tools,代码行数:18,代码来源:AddAzurePHPWorkerRoleTests.cs

示例15: NewAzureSBNamespaceWithInvalidLocation

        public void NewAzureSBNamespaceWithInvalidLocation()
        {
            // Setup
            SimpleServiceBusManagement channel = new SimpleServiceBusManagement();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            string location = "Invalid location";
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand(channel) { Name = name, Location = location, CommandRuntime = mockCommandRuntime };
            channel.ListServiceBusRegionsThunk = lsbr =>
            {
                List<ServiceBusRegion> list = new List<ServiceBusRegion>();
                list.Add(new ServiceBusRegion { Code = "West US" });
                return list;
            };
            string expected = string.Format("{0}\r\nParameter name: Location", string.Format(Resources.InvalidServiceBusLocation, location));

            Testing.AssertThrows<ArgumentException>(() => cmdlet.ExecuteCmdlet(), expected);
        }
开发者ID:johnkors,项目名称:azure-sdk-tools,代码行数:18,代码来源:NewAzureSBNamespaceTest.cs


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