Skip to content

Commit f1bd9ac

Browse files
Update client init test (#54268)
1 parent d33a7fc commit f1bd9ac

File tree

1 file changed

+19
-12
lines changed
  • eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Azure/ClientGeneratorCore/ClientInitialization

1 file changed

+19
-12
lines changed

eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/Http/Azure/ClientGeneratorCore/ClientInitialization/ClientInitializationTests.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,34 @@ public Task Azure_ClientGenerator_Core_ClientInitialization_ParamAlias() => Test
8383
});
8484

8585
[SpectorTest]
86-
[Ignore("The InitializedBy flag is not being respected. The Child client should have a public constructor.")]
8786
public Task Azure_ClientGenerator_Core_ClientInitialization_ParentClient_ChildClient() => Test(async (host) =>
8887
{
8988
// Create ParentClient with blobName elevated to client constructor
9089
var parentClient = new ParentClient(host, "sample-blob", null);
9190

9291
// Get ChildClient from ParentClient
9392
var childClient = parentClient.GetChildClient();
93+
await PerformClientOperations(childClient);
9494

95-
// Test WithQuery - blobName is elevated to parent client, format is method param
96-
await childClient.WithQueryAsync("text");
95+
// Can also create ChildClient directly with blobName elevated to parent client
96+
var directChildClient = new ChildClient(host, "sample-blob", null);
97+
await PerformClientOperations(directChildClient);
9798

98-
// Test GetStandalone - blobName is elevated to parent client
99-
var response = await childClient.GetStandaloneAsync();
100-
Assert.AreEqual("sample-blob", response.Value.Name);
101-
Assert.AreEqual(42, response.Value.Size);
102-
Assert.AreEqual("text/plain", response.Value.ContentType);
103-
Assert.AreEqual(new DateTimeOffset(2025, 4, 1, 12, 0, 0, TimeSpan.Zero), response.Value.CreatedOn);
104-
105-
// Test DeleteStandalone - blobName is elevated to parent client
106-
await childClient.DeleteStandaloneAsync();
99+
// Test WithQuery - blobName is elevated to parent client, format is method param
100+
async Task PerformClientOperations(ChildClient client)
101+
{
102+
await client.WithQueryAsync("text");
103+
104+
// Test GetStandalone - blobName is elevated to parent client
105+
var response = await client.GetStandaloneAsync();
106+
Assert.AreEqual("sample-blob", response.Value.Name);
107+
Assert.AreEqual(42, response.Value.Size);
108+
Assert.AreEqual("text/plain", response.Value.ContentType);
109+
Assert.AreEqual(new DateTimeOffset(2025, 4, 1, 12, 0, 0, TimeSpan.Zero), response.Value.CreatedOn);
110+
111+
// Test DeleteStandalone - blobName is elevated to parent client
112+
await client.DeleteStandaloneAsync();
113+
}
107114
});
108115
}
109116
}

0 commit comments

Comments
 (0)