-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add converage for http/client/naming (#4162)
Fixes #3966
- Loading branch information
Showing
27 changed files
with
1,685 additions
and
3 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
109 changes: 109 additions & 0 deletions
109
...tp-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/Client/Naming/NamingTests.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,109 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using Client.Naming; | ||
using Client.Naming.Models; | ||
using NUnit.Framework; | ||
using ClientModel = Client.Naming.Models.ClientModel; | ||
|
||
namespace TestProjects.CadlRanch.Tests.Http.Client.Naming | ||
{ | ||
public class ClientNamingTests : CadlRanchTestBase | ||
{ | ||
[CadlRanchTest] | ||
public Task Client() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).ClientAsync(new ClientNameModel(true)); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
Assert.NotNull(typeof(ClientNameModel).GetProperty("ClientName")); | ||
Assert.IsNull(typeof(ClientNameModel).GetProperty("DefaultName")); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Language() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).LanguageAsync(new LanguageClientNameModel(true)); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
Assert.NotNull(typeof(LanguageClientNameModel).GetProperty("CSName")); | ||
Assert.IsNull(typeof(LanguageClientNameModel).GetProperty("DefaultName")); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task CompatibleWithEncodedName() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).CompatibleWithEncodedNameAsync(new ClientNameAndJsonEncodedNameModel(true)); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
Assert.NotNull(typeof(ClientNameModel).GetProperty("ClientName")); | ||
Assert.IsNull(typeof(ClientNameModel).GetProperty("DefaultName")); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Operation() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).ClientNameAsync(); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Parameter() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).ParameterAsync(clientName: "true"); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Request() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).RequestAsync(clientName: "true"); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task Response() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).ResponseAsync(); | ||
Assert.IsTrue(response.GetRawResponse().Headers.TryGetValue("default-name", out _)); | ||
foreach (var header in response.GetRawResponse().Headers) | ||
{ | ||
var key = header.Key; | ||
if (key == "default-name") | ||
{ | ||
var value = header.Value; | ||
Assert.AreEqual("true", value); | ||
} | ||
} | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task ModelClient() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).GetClientModelClient().ClientAsync(new ClientModel(true)); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task ModelLanguage() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).GetClientModelClient().LanguageAsync(new CSModel(true)); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task UnionEnumName() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).GetUnionEnumClient().UnionEnumNameAsync(ClientExtensibleEnum.EnumValue1); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
|
||
[CadlRanchTest] | ||
public Task UnionEnumMemberName() => Test(async (host) => | ||
{ | ||
var response = await new NamingClient(host, null).GetUnionEnumClient().UnionEnumMemberNameAsync(ExtensibleEnum.ClientEnumValue1); | ||
Assert.AreEqual(204, response.GetRawResponse().Status); | ||
}); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
.../http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/Client.Naming.sln
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,48 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29709.97 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Naming", "src\Client.Naming.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} | ||
EndGlobalSection | ||
EndGlobal |
6 changes: 6 additions & 0 deletions
6
...http-client-csharp/generator/TestProjects/CadlRanch/http/client/naming/Configuration.json
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,6 @@ | ||
{ | ||
"output-folder": ".", | ||
"namespace": "Client.Naming", | ||
"library-name": "Client.Naming", | ||
"use-model-reader-writer": true | ||
} |
16 changes: 16 additions & 0 deletions
16
...lient-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Client.Naming.csproj
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<Description>This is the Client.Naming client library for developing .NET applications with rich experience.</Description> | ||
<AssemblyTitle>SDK Code Generation Client.Naming</AssemblyTitle> | ||
<Version>1.0.0-beta.1</Version> | ||
<PackageTags>Client.Naming</PackageTags> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.ClientModel" Version="1.1.0-beta.4" /> | ||
<PackageReference Include="System.Text.Json" Version="8.0.4" /> | ||
</ItemGroup> | ||
</Project> |
34 changes: 34 additions & 0 deletions
34
...t-csharp/generator/TestProjects/CadlRanch/http/client/naming/src/Generated/ClientModel.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,34 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System.ClientModel; | ||
using System.ClientModel.Primitives; | ||
using System.Threading.Tasks; | ||
using Client.Naming.Models; | ||
|
||
namespace Client.Naming | ||
{ | ||
public partial class ClientModel | ||
{ | ||
protected ClientModel() => throw null; | ||
|
||
public ClientPipeline Pipeline => throw null; | ||
|
||
public virtual ClientResult Client(BinaryContent content, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> ClientAsync(BinaryContent content, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult Client(Models.ClientModel body) => throw null; | ||
|
||
public virtual Task<ClientResult> ClientAsync(Models.ClientModel body) => throw null; | ||
|
||
public virtual ClientResult Language(BinaryContent content, RequestOptions options) => throw null; | ||
|
||
public virtual Task<ClientResult> LanguageAsync(BinaryContent content, RequestOptions options) => throw null; | ||
|
||
public virtual ClientResult Language(CSModel body) => throw null; | ||
|
||
public virtual Task<ClientResult> LanguageAsync(CSModel body) => throw null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...rator/TestProjects/CadlRanch/http/client/naming/src/Generated/ClientNamingModelFactory.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,19 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
namespace Client.Naming.Models | ||
{ | ||
public static partial class ClientNamingModelFactory | ||
{ | ||
public static ClientNameModel ClientNameModel(bool clientName = default) => throw null; | ||
|
||
public static LanguageClientNameModel LanguageClientNameModel(bool csName = default) => throw null; | ||
|
||
public static ClientNameAndJsonEncodedNameModel ClientNameAndJsonEncodedNameModel(bool clientName = default) => throw null; | ||
|
||
public static ClientModel ClientModel(bool defaultName = default) => throw null; | ||
|
||
public static CSModel CSModel(bool defaultName = default) => throw null; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...r/TestProjects/CadlRanch/http/client/naming/src/Generated/Models/CSModel.Serialization.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,36 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ClientModel; | ||
using System.ClientModel.Primitives; | ||
using System.Text.Json; | ||
|
||
namespace Client.Naming.Models | ||
{ | ||
public partial class CSModel : IJsonModel<CSModel> | ||
{ | ||
void IJsonModel<CSModel>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; | ||
|
||
protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null; | ||
|
||
CSModel IJsonModel<CSModel>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; | ||
|
||
protected virtual CSModel JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null; | ||
|
||
BinaryData IPersistableModel<CSModel>.Write(ModelReaderWriterOptions options) => throw null; | ||
|
||
protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null; | ||
|
||
CSModel IPersistableModel<CSModel>.Create(BinaryData data, ModelReaderWriterOptions options) => throw null; | ||
|
||
protected virtual CSModel PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null; | ||
|
||
string IPersistableModel<CSModel>.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null; | ||
|
||
public static implicit operator BinaryContent(CSModel csModel) => throw null; | ||
|
||
public static explicit operator CSModel(ClientResult result) => throw null; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...sharp/generator/TestProjects/CadlRanch/http/client/naming/src/Generated/Models/CSModel.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,18 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
namespace Client.Naming.Models | ||
{ | ||
public partial class CSModel | ||
{ | ||
public CSModel(bool defaultName) => throw null; | ||
|
||
public bool DefaultName | ||
{ | ||
get => throw null; | ||
set => throw null; | ||
} | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...or/TestProjects/CadlRanch/http/client/naming/src/Generated/Models/ClientExtensibleEnum.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,31 @@ | ||
// <auto-generated/> | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ComponentModel; | ||
|
||
namespace Client.Naming.Models | ||
{ | ||
public readonly partial struct ClientExtensibleEnum : IEquatable<ClientExtensibleEnum> | ||
{ | ||
public ClientExtensibleEnum(string value) => throw null; | ||
|
||
public static ClientExtensibleEnum EnumValue1 => throw null; | ||
|
||
public static bool operator ==(ClientExtensibleEnum left, ClientExtensibleEnum right) => throw null; | ||
|
||
public static bool operator !=(ClientExtensibleEnum left, ClientExtensibleEnum right) => throw null; | ||
|
||
public static implicit operator ClientExtensibleEnum(string value) => throw null; | ||
|
||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public override bool Equals(object obj) => throw null; | ||
|
||
public bool Equals(ClientExtensibleEnum other) => throw null; | ||
|
||
public override int GetHashCode() => throw null; | ||
|
||
public override string ToString() => throw null; | ||
} | ||
} |
Oops, something went wrong.