Skip to content

Commit 00141a1

Browse files
committed
test: add tests for base address and workspace id configure
1 parent 47a42d5 commit 00141a1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,36 @@ public void DashScopeClient_Constructor_WithApiKeyHeader()
7575
.BeEquivalentTo(new AuthenticationHeaderValue("Bearer", apiKey));
7676
}
7777

78+
[Fact]
79+
public void DashScopeClient_Constructor_WithWorkspaceId()
80+
{
81+
// Arrange
82+
const string apiKey = "key";
83+
const string workspaceId = "workspaceId";
84+
var client = new DashScopeClient(apiKey, null, null, workspaceId);
85+
86+
// Act
87+
var value = HttpClientAccessor.GetValue(client) as HttpClient;
88+
89+
// Assert
90+
value?.DefaultRequestHeaders.GetValues("X-DashScope-WorkSpace").Should().BeEquivalentTo(workspaceId);
91+
}
92+
93+
[Fact]
94+
public void DashScopeClient_Constructor_WithPrivateEndpoint()
95+
{
96+
// Arrange
97+
const string apiKey = "key";
98+
const string privateEndpoint = "https://dashscope.cnblogs.com/api/v1";
99+
var client = new DashScopeClient(apiKey, null, privateEndpoint);
100+
101+
// Act
102+
var value = HttpClientAccessor.GetValue(client) as HttpClient;
103+
104+
// Assert
105+
value?.BaseAddress.Should().BeEquivalentTo(new Uri(privateEndpoint));
106+
}
107+
78108
public static TheoryData<string, string, TimeSpan?, TimeSpan?> ParamsShouldNotCache
79109
=> new()
80110
{

0 commit comments

Comments
 (0)