From 240efa7ad801712117eb3624791431f92aa132d6 Mon Sep 17 00:00:00 2001 From: wiboris Date: Mon, 9 Oct 2023 14:07:31 -0700 Subject: [PATCH] feedback --- .../src/ProxyTransport.cs | 5 +-- .../src/RecordedTestBase.cs | 5 +-- .../src/TestRecording.cs | 32 +++---------------- 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs b/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs index a45944fb7b45b..61c8abdf0f227 100644 --- a/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs +++ b/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs @@ -135,11 +135,12 @@ public override Request CreateRequest() _recording.HasRequests = true; lock (_recording.Random) { - if (_recording.UseDefaultClientRequestIdFormat) + if (_recording.UseDefaultGuidFormatForClientRequestId) { // User want the client format to use the default format request.ClientRequestId = _recording.Random.NewGuid().ToString(); - }else + } + else { // Make sure ClientRequestId are the same across request and response request.ClientRequestId = _recording.Random.NewGuid().ToString("N"); diff --git a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs index 23328c8c3d29b..038fe523e5c77 100644 --- a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs +++ b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs @@ -150,10 +150,11 @@ public string ReplacementHost public bool CompareBodies { get; set; } = true; /// - /// Determines if during test recording if we should use the default guid format for clientID. + /// Determines if the ClientRequestId that is sent as part of a request while in Record mode + /// should use the default Guid format. The default Guid format contains hyphens. /// The default value is false. /// - public bool UseDefaultClientRequestIdFormat { get; set; } = false; + public bool UseDefaultGuidFormatForClientRequestId { get; set; } = false; /// /// Request headers whose values can change between recording and playback without causing request matching diff --git a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs index 191a18e4d2b1c..81a8affa14652 100644 --- a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs +++ b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs @@ -200,39 +200,15 @@ public TestRandom Random public string RecordingId { get; private set; } - private bool _useDefaultClientRequestIdFormat; - /// - /// Retrieves the value for the enviroment variable RECORDING_DEFAULT_ClIENT_GUID + /// Determines if the ClientRequestId that is sent as part of a request while in Record mode + /// should use the default Guid format. The default Guid format contains hyphens. /// - public bool UseDefaultClientRequestIdFormat + public bool UseDefaultGuidFormatForClientRequestId { get { - switch (Mode) - { - case RecordedTestMode.Live: - _useDefaultClientRequestIdFormat = false; - break; - case RecordedTestMode.Record: - _useDefaultClientRequestIdFormat = _recordedTestBase.UseDefaultClientRequestIdFormat; - Variables[DefaultClientGuidFormatInRecordingKey] = _useDefaultClientRequestIdFormat.ToString(); - break; - case RecordedTestMode.Playback: - ValidateVariables(); - try - { - _useDefaultClientRequestIdFormat = bool.Parse(Variables[DefaultClientGuidFormatInRecordingKey]); - } - catch (System.Collections.Generic.KeyNotFoundException) - { - _useDefaultClientRequestIdFormat = false; - } - break; - default: - throw new ArgumentOutOfRangeException(); - } - return _useDefaultClientRequestIdFormat; + return _recordedTestBase.UseDefaultGuidFormatForClientRequestId; } }