當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudFilesProvider.UpdateAccountMetadata方法代碼示例

本文整理匯總了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.UpdateAccountMetadata方法的典型用法代碼示例。如果您正苦於以下問題:C# CloudFilesProvider.UpdateAccountMetadata方法的具體用法?C# CloudFilesProvider.UpdateAccountMetadata怎麽用?C# CloudFilesProvider.UpdateAccountMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.openstack.Providers.Rackspace.CloudFilesProvider的用法示例。


在下文中一共展示了CloudFilesProvider.UpdateAccountMetadata方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_Add_MetaData_For_Account

        public void Should_Add_MetaData_For_Account()
        {
            var metaData = new Dictionary<string, string>();
            metaData.Add("Test-Accountmetadata", "Test");
            var provider = new CloudFilesProvider();
            provider.UpdateAccountMetadata(metaData, identity: _testIdentity);
            var accountHeadersResponse = provider.GetAccountMetaData(identity: _testIdentity);

            Assert.IsNotNull(accountHeadersResponse);
            Assert.IsTrue(accountHeadersResponse.ContainsKey("Test-Accountmetadata"));
            Assert.AreEqual("Test", accountHeadersResponse.Where(x => x.Key.Equals("Test-Accountmetadata", StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().Value);

        }
開發者ID:Dan-Pallone-II,項目名稱:openstack.net,代碼行數:13,代碼來源:CloudFilesTests.cs

示例2: TestUpdateAccountMetadata

        public void TestUpdateAccountMetadata()
        {
            IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
            Dictionary<string, string> metadata = provider.GetAccountMetaData();
            if (metadata.Any(i => i.Key.StartsWith(TestKeyPrefix, StringComparison.OrdinalIgnoreCase)))
            {
                Assert.Inconclusive("The account contains metadata from a previous unit test run. Run CleanupTestAccountMetadata and try again.");
                return;
            }

            // test add metadata
            TestGetAccountMetaData();
            provider.UpdateAccountMetadata(
                new Dictionary<string, string>
            {
                { TestKeyPrefix + "1", "Value ij" },
                { TestKeyPrefix + "2", "Value ²" },
            });
            TestGetAccountMetaData();

            Dictionary<string, string> expected =
                new Dictionary<string, string>
            {
                { TestKeyPrefix + "1", "Value ij" },
                { TestKeyPrefix + "2", "Value ²" },
            };
            CheckMetadataCollections(expected, GetAccountMetadataWithPrefix(provider, TestKeyPrefix));

            // test update metadata
            provider.UpdateAccountMetadata(
                new Dictionary<string, string>
            {
                { TestKeyPrefix + "1", "Value 1" },
            });

            expected = new Dictionary<string, string>
            {
                { TestKeyPrefix + "1", "Value 1" },
                { TestKeyPrefix + "2", "Value ²" },
            };
            CheckMetadataCollections(expected, GetAccountMetadataWithPrefix(provider, TestKeyPrefix));

            // test remove metadata
            provider.UpdateAccountMetadata(
                new Dictionary<string, string>
            {
                { TestKeyPrefix + "1", null },
                { TestKeyPrefix + "2", string.Empty },
            });

            expected = new Dictionary<string, string>();
            CheckMetadataCollections(expected, GetAccountMetadataWithPrefix(provider, TestKeyPrefix));
        }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:53,代碼來源:UserObjectStorageTests.cs

示例3: TestAccountInvalidHeaderKeyCharacters

        public void TestAccountInvalidHeaderKeyCharacters()
        {
            IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);

            List<char> validKeyCharList = new List<char>();
            for (char i = MinHeaderKeyCharacter; i <= MaxHeaderKeyCharacter; i++)
            {
                if (!SeparatorCharacters.Contains(i) && !NotSupportedCharacters.Contains(i))
                    validKeyCharList.Add(i);
            }

            for (int i = char.MinValue; i <= char.MaxValue; i++)
            {
                if (validKeyCharList.BinarySearch((char)i) >= 0)
                    continue;

                string invalidKey = new string((char)i, 1);

                try
                {
                    provider.UpdateAccountMetadata(
                        new Dictionary<string, string>
                        {
                            { invalidKey, "Value" }
                        });
                    Assert.Fail("Should throw an exception for invalid keys.");
                }
                catch (ArgumentException)
                {
                    if (i >= MinHeaderKeyCharacter && i <= MaxHeaderKeyCharacter)
                        StringAssert.Contains(SeparatorCharacters, invalidKey);
                }
                catch (NotSupportedException)
                {
                    StringAssert.Contains(NotSupportedCharacters, invalidKey);
                }
            }
        }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:38,代碼來源:UserObjectStorageTests.cs

示例4: TestAccountHeaderKeyCharacters

        public void TestAccountHeaderKeyCharacters()
        {
            IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);

            List<char> keyCharList = new List<char>();
            for (char i = MinHeaderKeyCharacter; i <= MaxHeaderKeyCharacter; i++)
            {
                if (!SeparatorCharacters.Contains(i) && !NotSupportedCharacters.Contains(i))
                    keyCharList.Add(i);
            }

            string key = TestKeyPrefix + new string(keyCharList.ToArray());
            Console.WriteLine("Expected key: {0}", key);

            provider.UpdateAccountMetadata(
                new Dictionary<string, string>
                {
                    { key, "Value" }
                });

            Dictionary<string, string> metadata = provider.GetAccountMetaData();
            Assert.IsNotNull(metadata);

            string value;
            Assert.IsTrue(metadata.TryGetValue(key, out value));
            Assert.AreEqual("Value", value);

            provider.UpdateAccountMetadata(
                new Dictionary<string, string>
                {
                    { key, null }
                });

            metadata = provider.GetAccountMetaData();
            Assert.IsNotNull(metadata);
            Assert.IsFalse(metadata.TryGetValue(key, out value));
        }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:37,代碼來源:UserObjectStorageTests.cs

示例5: CleanupTestAccountMetadata

 public void CleanupTestAccountMetadata()
 {
     IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
     Dictionary<string, string> metadata = GetAccountMetadataWithPrefix(provider, TestKeyPrefix);
     Dictionary<string, string> removedMetadata = metadata.ToDictionary(i => i.Key, i => string.Empty);
     provider.UpdateAccountMetadata(removedMetadata);
 }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:7,代碼來源:UserObjectStorageTests.cs

示例6: Should_Update_Headers_For_Account

        public void Should_Update_Headers_For_Account()
        {
            var headers = new Dictionary<string, string>();
            headers.Add("Test-Accountmetadata", "Test1");

            var provider = new CloudFilesProvider();
            provider.UpdateAccountMetadata(headers, identity: _testIdentity);
            var accountHeadersResponse = provider.GetAccountMetaData(identity: _testIdentity);

            Assert.IsNotNull(accountHeadersResponse);
            string value;
            Assert.IsTrue(accountHeadersResponse.TryGetValue("Test-Accountmetadata", out value));
            Assert.AreEqual("Test1", value);
        }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:14,代碼來源:CloudFilesTests.cs


注:本文中的net.openstack.Providers.Rackspace.CloudFilesProvider.UpdateAccountMetadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。