From b5290c9be249e9aae8187ef57b1e6b424aeec122 Mon Sep 17 00:00:00 2001 From: Caio Saldanha Date: Mon, 25 Sep 2023 12:08:57 -0700 Subject: [PATCH] Addressed PR comments --- .../src/ConfigurationClient_private.cs | 26 ----- .../src/Models/SettingFieldsExtensions.cs | 5 + .../tests/ConfigurationSettingTests.cs | 108 ------------------ 3 files changed, 5 insertions(+), 134 deletions(-) diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient_private.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient_private.cs index 1d91239c3a1c8..f211883ea397f 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient_private.cs +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient_private.cs @@ -52,32 +52,6 @@ private static void ParseConnectionString(string connectionString, out Uri uri, } } - internal static void BuildBatchQuery(RequestUriBuilder builder, SettingSelector selector, string pageLink) - { - if (!string.IsNullOrEmpty(selector.KeyFilter)) - { - builder.AppendQuery(KeyQueryFilter, selector.KeyFilter); - } - - if (!string.IsNullOrEmpty(selector.LabelFilter)) - { - builder.AppendQuery(LabelQueryFilter, selector.LabelFilter); - } - - IEnumerable splitFields = selector.Fields.Split(); - - if (splitFields != null) - { - string filter = string.Join(",", splitFields); - builder.AppendQuery(FieldsQueryFilter, filter); - } - - if (!string.IsNullOrEmpty(pageLink)) - { - builder.AppendQuery("after", pageLink, escapeValue: false); - } - } - #region nobody wants to see these /// /// Check if two ConfigurationSetting instances are equal. diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/SettingFieldsExtensions.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/SettingFieldsExtensions.cs index 1880b4d4cba3f..081c605d29ce1 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/SettingFieldsExtensions.cs +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/Models/SettingFieldsExtensions.cs @@ -22,6 +22,11 @@ internal static class SettingFieldsExtensions { SettingFields.Tags , "tags" } }; + /// + /// Splits flags into their corresponding service names. + /// + /// The flags to split. + /// An enumerable containing the names of the flags. The method returns null for . public static IEnumerable Split(this SettingFields fields) { if (fields == SettingFields.All) diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/ConfigurationSettingTests.cs b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/ConfigurationSettingTests.cs index 3cd8ba0cc4665..096f99e0b1b72 100644 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/ConfigurationSettingTests.cs +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/tests/ConfigurationSettingTests.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; namespace Azure.Data.AppConfiguration.Tests { @@ -28,113 +27,6 @@ public class ConfigurationSettingTests } }; - [Test] - public void FilterReservedCharacter() - { - var selector = new SettingSelector - { - KeyFilter = @"my_key,key\,key", - LabelFilter = @"my_label,label\,label" - }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual(@"http://localhost/?key=my_key%2Ckey%5C%2Ckey&label=my_label%2Clabel%5C%2Clabel", builder.ToUri().AbsoluteUri); - } - - [Test] - public void FilterContains() - { - var selector = new SettingSelector{ KeyFilter = "*key*", LabelFilter = "*label*" }; - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual("http://localhost/?key=%2Akey%2A&label=%2Alabel%2A", builder.ToUri().AbsoluteUri); - } - - [Test] - public void FilterNullLabel() - { - var selector = new SettingSelector { LabelFilter = "\0" }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual("http://localhost/?label=%00", builder.ToUri().AbsoluteUri); - } - - [Test] - public void FilterOnlyKey() - { - var key = "my-key"; - var selector = new SettingSelector { KeyFilter = key }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual($"http://localhost/?key={key}", builder.ToUri().AbsoluteUri); - } - - [Test] - public void FilterOnlyLabel() - { - var label = "my-label"; - var selector = new SettingSelector - { - LabelFilter = label - }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual($"http://localhost/?label={label}", builder.ToUri().AbsoluteUri); - } - - [Test] - public void SettingSomeFields() - { - var selector = new SettingSelector - { - KeyFilter = "key", - Fields = SettingFields.Key | SettingFields.Value - }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual($"http://localhost/?key=key&$select=key%2Cvalue", builder.ToUri().AbsoluteUri); - } - - [Test] - public void SettingAllFields() - { - var selector = new SettingSelector - { - KeyFilter = "key", - Fields = SettingFields.All - }; - - var builder = new RequestUriBuilder(); - builder.Reset(new Uri("http://localhost/")); - - ConfigurationClient.BuildBatchQuery(builder, selector, null); - - Assert.AreEqual($"http://localhost/?key=key", builder.ToUri().AbsoluteUri); - } - [Test] public void ConfigurationSettingEquals() {