-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[http-client-csharp] adopt http\resiliency\srv-driven (#5142)
fixes: #3983
- Loading branch information
1 parent
432ca32
commit 1cf8601
Showing
23 changed files
with
1,170 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
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
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
77 changes: 77 additions & 0 deletions
77
...arp/generator/TestProjects/CadlRanch.Tests/Http/Resiliency/SrvDriven/SrvDrivenTests.V1.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,77 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using NUnit.Framework; | ||
using Resiliency.ServiceDriven.V1; | ||
using System.Threading.Tasks; | ||
|
||
namespace TestProjects.CadlRanch.Tests.Http.Resiliency.SrvDriven | ||
{ | ||
/// <summary> | ||
/// Contains tests for the service-driven resiliency V1 client. | ||
/// </summary> | ||
public partial class SrvDrivenTests : CadlRanchTestBase | ||
{ | ||
// This test validates the v1 client behavior when both the service deployment and api version are set to V1. | ||
[CadlRanchTest] | ||
public Task AddOptionalParamFromNone_V1Client_V1Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV1, options); | ||
var response = await client.FromNoneAsync(); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
// This test validates the v1 client behavior when the service deployment is set to V2 and the api version is set to V1. | ||
[CadlRanchTest] | ||
public Task AddOptionalParamFromNone_V1Client_V2Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromNoneAsync(); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneOptional_V1Client_V1Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV1, options); | ||
var response = await client.FromOneOptionalAsync("optional"); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneOptional_V1Client_V2Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneOptionalAsync("optional", cancellationToken: default); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneRequired_V1Client_V1Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV1, options); | ||
var response = await client.FromOneRequiredAsync("required"); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneRequired_V1Client_V2Service_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneRequiredAsync("required"); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...csharp/generator/TestProjects/CadlRanch.Tests/Http/Resiliency/SrvDriven/SrvDrivenTests.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,86 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using NUnit.Framework; | ||
using System.Threading.Tasks; | ||
using Resiliency.ServiceDriven; | ||
|
||
namespace TestProjects.CadlRanch.Tests.Http.Resiliency.SrvDriven | ||
{ | ||
public partial class SrvDrivenTests : CadlRanchTestBase | ||
{ | ||
private const string ServiceDeploymentV1 = "v1"; | ||
private const string ServiceDeploymentV2 = "v2"; | ||
|
||
[CadlRanchTest] | ||
public Task AddOperation() => Test(async (host) => | ||
{ | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2); | ||
var response = await client.AddOperationAsync(); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
// This test validates the "new" client behavior when the api version is set to V1. | ||
[CadlRanchTest] | ||
public Task AddOptionalParamFromNone_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromNoneAsync(); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
// This test validates the "new" client behavior when the api version is set to V2. | ||
[CadlRanchTest] | ||
public Task AddOptionalParamFromNone_WithApiVersionV2() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V2); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromNoneAsync("new", cancellationToken: default); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneOptional_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneOptionalAsync("optional"); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneOptional_WithApiVersionV2() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V2); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneOptionalAsync("optional", "new", cancellationToken: default); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneRequired_WithApiVersionV1() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V1); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneRequiredAsync("required"); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task AddOptionalParamFromOneRequired_WithApiVersionV2() => Test(async (host) => | ||
{ | ||
var options = new ResiliencyServiceDrivenClientOptions(ResiliencyServiceDrivenClientOptions.ServiceVersion.V2); | ||
var client = new ResiliencyServiceDrivenClient(host, ServiceDeploymentV2, options); | ||
var response = await client.FromOneRequiredAsync("required", "new", cancellationToken: default); | ||
|
||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
} | ||
} |
Oops, something went wrong.