Added the custom-baseUrl-more-options test.
This commit is contained in:
Родитель
94e3dc60e7
Коммит
a43baa4b3a
|
@ -21,7 +21,7 @@ $repoRoot = "$PSScriptRoot\.."
|
|||
$testServerTestProject = Resolve-Path "$repoRoot\test\AutoRest.TestServer.Tests"
|
||||
$testConfiguration = Resolve-Path "$testServerTestProject\readme.md"
|
||||
$testServerSwaggerPath = Resolve-Path "$repoRoot\node_modules\@autorest\test-server\__files\swagger"
|
||||
$paths = 'body-string', 'body-complex', 'custom-baseUrl'
|
||||
$paths = 'body-string', 'body-complex', 'custom-baseUrl', 'custom-baseUrl-more-options'
|
||||
$debugFlags = if($NoDebug) { '' } else { '--debug --verbose' }
|
||||
|
||||
foreach ($path in $paths)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
using System.Threading.Tasks;
|
||||
using custom_baseUrl_more_options.Operations.V100;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace AutoRest.TestServer.Tests
|
||||
{
|
||||
public class custom_baseUrl_more_options : TestServerTestBase
|
||||
{
|
||||
[Test]
|
||||
public async Task GetEmpty()
|
||||
{
|
||||
await using var server = TestServerSession.Start("customuri_test12_key1");
|
||||
|
||||
var result = PathsOperations.GetEmptyAsync(ClientDiagnostics, Pipeline, server.Host, string.Empty, "key1", "test12", string.Empty, "v1").GetAwaiter().GetResult();
|
||||
Assert.AreEqual(200, result.Status);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Text.Json;
|
||||
|
||||
namespace custom_baseUrl_more_options.Models.V100
|
||||
{
|
||||
public partial class Error
|
||||
{
|
||||
internal void Serialize(Utf8JsonWriter writer, bool includeName = true)
|
||||
{
|
||||
if (includeName)
|
||||
{
|
||||
writer.WriteStartObject("Error");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteStartObject();
|
||||
}
|
||||
if (Status != null)
|
||||
{
|
||||
writer.WriteNumber("status", Status.Value);
|
||||
}
|
||||
if (Message != null)
|
||||
{
|
||||
writer.WriteString("message", Message);
|
||||
}
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
internal static Error Deserialize(JsonElement element)
|
||||
{
|
||||
var result = new Error();
|
||||
foreach (var property in element.EnumerateObject())
|
||||
{
|
||||
if (property.NameEquals("status"))
|
||||
{
|
||||
result.Status = property.Value.GetInt32();
|
||||
continue;
|
||||
}
|
||||
if (property.NameEquals("message"))
|
||||
{
|
||||
result.Message = property.Value.GetString();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace custom_baseUrl_more_options.Models.V100
|
||||
{
|
||||
public partial class Error
|
||||
{
|
||||
public int? Status { get; set; }
|
||||
public string? Message { get; set; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Azure;
|
||||
using Azure.Core;
|
||||
using Azure.Core.Pipeline;
|
||||
|
||||
namespace custom_baseUrl_more_options.Operations.V100
|
||||
{
|
||||
public static class PathsOperations
|
||||
{
|
||||
public static async ValueTask<Response> GetEmptyAsync(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string vault, string secret, string keyName, string subscriptionId, string dnsSuffix = "host", string? keyVersion = default, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using var scope = clientDiagnostics.CreateScope("custom_baseUrl_more_options.Operations.V100.GetEmpty");
|
||||
scope.Start();
|
||||
try
|
||||
{
|
||||
var request = pipeline.CreateRequest();
|
||||
request.Method = RequestMethod.Get;
|
||||
request.Uri.Reset(new Uri($"{vault}{secret}{dnsSuffix}/customuri/{subscriptionId}/{keyName}"));
|
||||
if (keyVersion != null)
|
||||
{
|
||||
request.Uri.AppendQuery("keyVersion", keyVersion.ToString()!);
|
||||
}
|
||||
var response = await pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
return response;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
scope.Failed(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче