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


C# CloudServersProvider.ListServerMetadata方法代码示例

本文整理汇总了C#中CloudServersProvider.ListServerMetadata方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider.ListServerMetadata方法的具体用法?C# CloudServersProvider.ListServerMetadata怎么用?C# CloudServersProvider.ListServerMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CloudServersProvider的用法示例。


在下文中一共展示了CloudServersProvider.ListServerMetadata方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CloudServersProvider

        public void Should_Get_The_List_Of_Metadata_Items_Including_Keys_3_And_5_But_Excluding_The_Deleted_Item_With_Key_4()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var metadata = provider.ListServerMetadata(_testServer.Id);

            Assert.IsNotNull(metadata);
            Assert.IsTrue(metadata.Count == 2);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_3"));
            Assert.AreEqual("My_Value_3_Updated_Again", metadata.First(md => md.Key == "Metadata_Key_3").Value);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_5"));
            Assert.AreEqual("My_Value_5_Updated", metadata.First(md => md.Key == "Metadata_Key_5").Value);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:12,代码来源:CloudServersTests.cs

示例2: Should_Get_The_Server_Metadata_Including_The_New_Item_With_Key_5

        public void Should_Get_The_Server_Metadata_Including_The_New_Item_With_Key_5()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var metadata = provider.ListServerMetadata(_testServer.Id);

            Assert.IsNotNull(metadata);
            Assert.IsTrue(metadata.Count == 3);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_3"));
            Assert.AreEqual("My_Value_3_Updated", metadata.First(md => md.Key == "Metadata_Key_3").Value);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_4"));
            Assert.AreEqual("My_Value_4_Updated", metadata.First(md => md.Key == "Metadata_Key_4").Value);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_5"));
            Assert.AreEqual("My_Value_5", metadata.First(md => md.Key == "Metadata_Key_5").Value);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:14,代码来源:CloudServersTests.cs

示例3: Should_Get_The_Reset_Test_Server_Metadata_With_Keys_3_and_4

        public void Should_Get_The_Reset_Test_Server_Metadata_With_Keys_3_and_4()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var metadata = provider.ListServerMetadata(_testServer.Id);

            Assert.IsNotNull(metadata);
            Assert.IsTrue(metadata.Count == 2);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_3"));
            Assert.AreEqual("My_Value_3", metadata.First(md => md.Key == "Metadata_Key_3").Value);
            Assert.IsTrue(metadata.Any(md => md.Key == "Metadata_Key_4"));
            Assert.AreEqual("My_Value_4", metadata.First(md => md.Key == "Metadata_Key_4").Value);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:12,代码来源:CloudServersTests.cs

示例4: Should_Get_Empty_Server_Metadata_List

        public void Should_Get_Empty_Server_Metadata_List()
        {
            var provider = new CloudServersProvider(_testIdentity);
            var metadata = provider.ListServerMetadata(_testServer.Id);

            Assert.IsNotNull(metadata);
            Assert.IsTrue(metadata.Count == 0);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs

示例5: TestServerMetadata

        public void TestServerMetadata()
        {
            IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);

            Metadata initialMetadata = provider.ListServerMetadata(_server.Id);
            if (initialMetadata.Count > 0)
            {
                Console.WriteLine("Actual metadata");
                foreach (KeyValuePair<string, string> meta in initialMetadata)
                    Console.WriteLine("  {0}: {1}", meta.Key, meta.Value);

                Assert.Inconclusive("Expected the server to not have any initial metadata.");
            }

            Assert.IsTrue(provider.SetServerMetadataItem(_server.Id, "Item 1", "Value"));
            Assert.AreEqual("Value", provider.GetServerMetadataItem(_server.Id, "Item 1"));
            Assert.IsTrue(provider.SetServerMetadataItem(_server.Id, "Item 2", "Value ²"));
            Assert.AreEqual("Value ²", provider.GetServerMetadataItem(_server.Id, "Item 2"));

            // setting the same key overwrites the previous value
            Assert.IsTrue(provider.SetServerMetadataItem(_server.Id, "Item 1", "Value 1"));
            Assert.AreEqual("Value 1", provider.GetServerMetadataItem(_server.Id, "Item 1"));

            Assert.IsTrue(provider.DeleteServerMetadataItem(_server.Id, "Item 1"));
            Assert.IsFalse(provider.ListServerMetadata(_server.Id).ContainsKey("Item 1"));

            Metadata metadata = new Metadata()
            {
                { "Different", "Variables" },
            };

            Assert.IsTrue(provider.UpdateServerMetadata(_server.Id, metadata));
            Metadata actual = provider.ListServerMetadata(_server.Id);
            Assert.IsNotNull(actual);
            Assert.AreEqual(2, actual.Count);
            Assert.AreEqual("Value ²", actual["Item 2"]);
            Assert.AreEqual("Variables", actual["Different"]);

            // a slight tweak
            metadata["Different"] = "Values";
            Assert.IsTrue(provider.SetServerMetadata(_server.Id, metadata));
            actual = provider.ListServerMetadata(_server.Id);
            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Count);
            Assert.AreEqual("Values", actual["Different"]);

            Assert.IsTrue(provider.SetServerMetadata(_server.Id, new Metadata()));
            Assert.AreEqual(0, provider.ListServerMetadata(_server.Id).Count);
        }
开发者ID:nick-o,项目名称:openstack.net,代码行数:49,代码来源:UserServerTests.cs


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