Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wiboris committed Oct 9, 2023
1 parent 50d0149 commit 240efa7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
5 changes: 3 additions & 2 deletions sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 3 additions & 2 deletions sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,11 @@ public string ReplacementHost
public bool CompareBodies { get; set; } = true;

/// <summary>
/// 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 <value>false</value>.
/// </summary>
public bool UseDefaultClientRequestIdFormat { get; set; } = false;
public bool UseDefaultGuidFormatForClientRequestId { get; set; } = false;

/// <summary>
/// Request headers whose values can change between recording and playback without causing request matching
Expand Down
32 changes: 4 additions & 28 deletions sdk/core/Azure.Core.TestFramework/src/TestRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,39 +200,15 @@ public TestRandom Random

public string RecordingId { get; private set; }

private bool _useDefaultClientRequestIdFormat;

/// <summary>
/// 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.
/// </summary>
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;
}
}

Expand Down

0 comments on commit 240efa7

Please sign in to comment.