Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Jan 10, 2025
1 parent b42a16f commit 3b39806
Show file tree
Hide file tree
Showing 60 changed files with 1,955 additions and 1,266 deletions.
4 changes: 3 additions & 1 deletion packages/http-client-csharp/eng/scripts/Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ $failingSpecs = @(
Join-Path 'http' 'type' 'model' 'flatten'
Join-Path 'http' 'type' 'model' 'templated'
Join-Path 'http' 'client' 'naming'
Join-Path 'http' 'parameters' 'spread'
Join-Path 'http' 'resiliency' 'srv-driven' 'v2'
Join-Path 'http' 'special-words'
)

$azureAllowSpecs = @(
Expand All @@ -63,7 +66,6 @@ $azureAllowSpecs = @(
Join-Path 'http' 'client' 'structure' 'multi-client'
Join-Path 'http' 'client' 'structure' 'renamed-operation'
Join-Path 'http' 'client' 'structure' 'two-operation-group'
Join-Path 'http' 'resiliency' 'srv-driven'
)

$cadlRanchLaunchProjects = @{}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,109 +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;
// 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);
// 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"));
});
// 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);
// [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"));
});
// 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);
// [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"));
});
// 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 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 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 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 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 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 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 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);
});
}
// [CadlRanchTest]
// public Task UnionEnumMemberName() => Test(async (host) =>
// {
// var response = await new NamingClient(host, null).GetUnionEnumClient().UnionEnumMemberNameAsync(ExtensibleEnum.ClientEnumValue1);
// Assert.AreEqual(204, response.GetRawResponse().Status);
// });
// }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Client.Structure.Service;
using Client.Structure.Service.Models;
using NUnit.Framework;
using System.Linq;
using System.Threading.Tasks;
using Client.Structure.Service;
using Client.Structure.Service.Models;
using NUnit.Framework;

namespace TestProjects.CadlRanch.Tests.Http.Client.Structure.ClientOperationGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Client.Structure.Service.Default;
using Client.Structure.Service.Default.Models;
using Client.Structure.Service.Renamed.Operation;
using NUnit.Framework;

namespace TestProjects.CadlRanch.Tests.Http.Client.Structure.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\client\structure\multi-client\src\Client.Structure.Service.MultiClient.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\client\structure\multi-client\src\Client.Structure.Service.Multi.Client.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\client\structure\renamed-operation\src\Client.Structure.Service.RenamedOperation.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\client\structure\renamed-operation\src\Client.Structure.Service.Renamed.Operation.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\type\model\inheritance\not-discriminator\src\_Type.Model.Inheritance.NotDiscriminator.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\encode\bytes\src\Encode.Bytes.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\encode\datetime\src\Encode.DateTime.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\encode\duration\src\Encode.Duration.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\encode\numeric\src\Encode.Numeric.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\parameters\basic\src\Parameters.Basic.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\parameters\body-optionality\src\Parameters.BodyOptionality.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\parameters\collection-format\src\Parameters.CollectionFormat.csproj" />
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="System.Memory.Data" />
<PackageReference Include="System.ClientModel" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\Microsoft.Generator.CSharp\test\common\Microsoft.Generator.CSharp.Tests.Common.csproj" />
<!-- <ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch\http\parameters\spread\src\Parameters.Spread.csproj" /> -->
<ProjectReference Include="$(RepoRoot)\TestProjects\CadlRanch.Tests\TestProjects.CadlRanch.Tests.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 3b39806

Please sign in to comment.