forked from Azure/autorest.csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,430 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using AutoRest.TestServer.Tests.Infrastructure; | ||
using Azure; | ||
using Azure.Core; | ||
using Enums.Extensible; | ||
using Enums.Extensible.Models; | ||
using NUnit.Framework; | ||
|
||
namespace CadlRanchProjects.Tests | ||
{ | ||
public class EnumsExtensibleTests : CadlRanchTestBase | ||
{ | ||
[Test] | ||
public Task Enums_Extensible_String_getKnownValue() => Test(async (host) => | ||
{ | ||
Response response = await new ExtensibleClient(host, null).GetKnownValueAsync(); | ||
JsonData result = JsonData.FromBytes(response.Content.ToMemory()); | ||
Assert.AreEqual(DaysOfWeekExtensibleEnum.Monday, new DaysOfWeekExtensibleEnum((string)result)); | ||
}); | ||
|
||
[Test] | ||
public Task Enums_Extensible_String_putKnownValue() => Test(async (host) => | ||
{ | ||
Response response = await new ExtensibleClient(host, null).GetUnknownValueAsync(); | ||
JsonData result = JsonData.FromBytes(response.Content.ToMemory()); | ||
Assert.AreEqual(new DaysOfWeekExtensibleEnum("Weekend"), new DaysOfWeekExtensibleEnum((string)result)); | ||
}); | ||
|
||
[Test] | ||
public Task Enums_Extensible_String_getUnknownValue() => Test(async (host) => | ||
{ | ||
Response response = await new ExtensibleClient(host, null).PutKnownValueAsync(RequestContent.Create(new JsonData(DaysOfWeekExtensibleEnum.Monday.ToString()))); | ||
Assert.AreEqual(204, response.Status); | ||
}); | ||
|
||
[Test] | ||
public Task Enums_Extensible_String_putUnknownValue() => Test(async (host) => | ||
{ | ||
Response response = await new ExtensibleClient(host, null).PutUnknownValueAsync(RequestContent.Create(new JsonData(new DaysOfWeekExtensibleEnum("Weekend").ToString()))); | ||
Assert.AreEqual(204, response.Status); | ||
}); | ||
} | ||
} |
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,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using AutoRest.TestServer.Tests.Infrastructure; | ||
using Azure; | ||
using Azure.Core; | ||
using Hello; | ||
using NUnit.Framework; | ||
|
||
namespace CadlRanchProjects.Tests | ||
{ | ||
public class HelloTests : CadlRanchTestBase | ||
{ | ||
[Test] | ||
public Task Hello_world() => Test(async (host) => | ||
{ | ||
Response response = await new HelloClient(host, null).WorldAsync(); | ||
Assert.AreEqual(200, response.Status); | ||
Assert.AreEqual("application/json; charset=utf-8", response.Headers.ContentType); | ||
JsonData responseBody = JsonData.FromBytes(response.Content.ToMemory()); | ||
Assert.AreEqual("Hello World!", (string)responseBody); | ||
}); | ||
} | ||
} |
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,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<Nullable>annotations</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DefineConstants>$(DefineConstants);EXPERIMENTAL</DefineConstants> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Azure.Core.Experimental" Version="0.1.0-preview.18" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Core" Version="1.28.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
10 changes: 10 additions & 0 deletions
10
test/CadlRanchProjects/enums/extensible/Generated/Configuration.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
109 changes: 109 additions & 0 deletions
109
test/CadlRanchProjects/enums/extensible/Generated/Docs/ExtensibleClient.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<doc> | ||
<members> | ||
<member name="GetKnownValueAsync(RequestContext)"> | ||
<example> | ||
This sample shows how to call GetKnownValueAsync and parse the result. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
Response response = await client.GetKnownValueAsync(); | ||
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; | ||
Console.WriteLine(result.ToString()); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="GetKnownValue(RequestContext)"> | ||
<example> | ||
This sample shows how to call GetKnownValue and parse the result. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
Response response = client.GetKnownValue(); | ||
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; | ||
Console.WriteLine(result.ToString()); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="GetUnknownValueAsync(RequestContext)"> | ||
<example> | ||
This sample shows how to call GetUnknownValueAsync and parse the result. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
Response response = await client.GetUnknownValueAsync(); | ||
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; | ||
Console.WriteLine(result.ToString()); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="GetUnknownValue(RequestContext)"> | ||
<example> | ||
This sample shows how to call GetUnknownValue and parse the result. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
Response response = client.GetUnknownValue(); | ||
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; | ||
Console.WriteLine(result.ToString()); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="PutKnownValueAsync(RequestContent,RequestContext)"> | ||
<example> | ||
This sample shows how to call PutKnownValueAsync with required request content. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
var data = "Monday"; | ||
Response response = await client.PutKnownValueAsync(RequestContent.Create(data)); | ||
Console.WriteLine(response.Status); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="PutKnownValue(RequestContent,RequestContext)"> | ||
<example> | ||
This sample shows how to call PutKnownValue with required request content. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
var data = "Monday"; | ||
Response response = client.PutKnownValue(RequestContent.Create(data)); | ||
Console.WriteLine(response.Status); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="PutUnknownValueAsync(RequestContent,RequestContext)"> | ||
<example> | ||
This sample shows how to call PutUnknownValueAsync with required request content. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
var data = "Monday"; | ||
Response response = await client.PutUnknownValueAsync(RequestContent.Create(data)); | ||
Console.WriteLine(response.Status); | ||
]]></code> | ||
</example> | ||
</member> | ||
<member name="PutUnknownValue(RequestContent,RequestContext)"> | ||
<example> | ||
This sample shows how to call PutUnknownValue with required request content. | ||
<code><![CDATA[ | ||
var client = new ExtensibleClient(); | ||
var data = "Monday"; | ||
Response response = client.PutUnknownValue(RequestContent.Create(data)); | ||
Console.WriteLine(response.Status); | ||
]]></code> | ||
</example> | ||
</member> | ||
</members> | ||
</doc> |
Oops, something went wrong.