-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle repeatability header params in client (#4203)
Fixes: #3936
- Loading branch information
1 parent
da540e1
commit 261fa52
Showing
8 changed files
with
173 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ders/ClientProviders/TestData/RestClientProviderTests/ValidateClientWithSpecialHeaders.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ClientModel; | ||
using System.ClientModel.Primitives; | ||
|
||
namespace sample.namespace | ||
{ | ||
/// <summary></summary> | ||
public partial class TestClient | ||
{ | ||
internal global::System.ClientModel.Primitives.PipelineMessage CreateCreateMessageRequest(global::System.ClientModel.BinaryContent content, global::System.ClientModel.Primitives.RequestOptions options) | ||
{ | ||
global::System.ClientModel.Primitives.PipelineMessage message = Pipeline.CreateMessage(); | ||
message.ResponseClassifier = PipelineMessageClassifier200; | ||
global::System.ClientModel.Primitives.PipelineRequest request = message.Request; | ||
request.Method = "GET"; | ||
global::sample.namespace.ClientUriBuilder uri = new global::sample.namespace.ClientUriBuilder(); | ||
uri.Reset(_endpoint); | ||
request.Uri = uri.ToUri(); | ||
request.Headers.Set("repeatability-first-sent", global::System.DateTimeOffset.Now.ToString("R")); | ||
request.Headers.Set("repeatability-request-ID", global::System.Guid.NewGuid().ToString()); | ||
request.Content = content; | ||
message.Apply(options); | ||
return message; | ||
} | ||
} | ||
} |
28 changes: 26 additions & 2 deletions
28
...t-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/ScmKnownParametersTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Microsoft.Generator.CSharp.ClientModel.Primitives; | ||
using Microsoft.Generator.CSharp.Primitives; | ||
using NUnit.Framework; | ||
using static Microsoft.Generator.CSharp.Snippets.Snippet; | ||
|
||
namespace Microsoft.Generator.CSharp.ClientModel.Tests | ||
{ | ||
public class ScmKnownParametersTests | ||
{ | ||
[Test] | ||
public void BinaryDataParametersHasValidation() | ||
[OneTimeSetUp] | ||
public void Setup() | ||
{ | ||
MockHelpers.LoadMockPlugin(); | ||
|
||
} | ||
|
||
[Test] | ||
public void BinaryDataParameterHasValidation() | ||
{ | ||
var parameter = ScmKnownParameters.BinaryContent; | ||
Assert.AreEqual(ParameterValidationType.AssertNotNull, parameter.Validation); | ||
} | ||
|
||
[Test] | ||
public void RepeatabilityRequestIdParamHasDefaultValue() | ||
{ | ||
var parameter = ScmKnownParameters.RepeatabilityRequestId; | ||
var expectedDefaultValue = Static(typeof(Guid)).Invoke(nameof(Guid.NewGuid)).Invoke(nameof(string.ToString)); | ||
Assert.AreEqual(expectedDefaultValue, parameter.DefaultValue); | ||
} | ||
|
||
[Test] | ||
public void RepeatabilityFirstSentParamHasDefaultValue() | ||
{ | ||
var parameter = ScmKnownParameters.RepeatabilityFirstSent; | ||
var expectedDefaultValue = Static(typeof(DateTimeOffset)).Property(nameof(DateTimeOffset.Now)); | ||
Assert.AreEqual(expectedDefaultValue, parameter.DefaultValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters