diff --git a/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj b/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj
index fd1bb50..ef379a0 100644
--- a/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj
+++ b/sample/Cnblogs.DashScope.Sample/Cnblogs.DashScope.Sample.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj b/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj
index c34f277..5e45397 100644
--- a/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj
+++ b/src/Cnblogs.DashScope.AI/Cnblogs.DashScope.AI.csproj
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs b/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs
index 84f54c9..8bd80fa 100644
--- a/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs
+++ b/test/Cnblogs.DashScope.AI.UnitTests/ChatClientTests.cs
@@ -1,7 +1,7 @@
using System.Text;
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+
using Microsoft.Extensions.AI;
using NSubstitute;
using NSubstitute.Extensions;
@@ -46,7 +46,7 @@ public async Task ChatClient_TextCompletion_SuccessAsync()
Arg.Is>(
m => m.IsEquivalent(testCase.RequestModel)),
Arg.Any());
- response.Messages[0].Text.Should().Be(testCase.ResponseModel.Output.Choices?.First().Message.Content);
+ Assert.Equal(testCase.ResponseModel.Output.Choices![0].Message.Content, response.Messages[0].Text);
}
[Fact]
@@ -93,7 +93,7 @@ public async Task ChatClient_TextCompletionStream_SuccessAsync()
Arg.Is>(
m => m.IsEquivalent(testCase.RequestModel)),
Arg.Any());
- text.ToString().Should().Be(testCase.ResponseModel.Output.Choices?.First().Message.Content);
+ Assert.Equal(testCase.ResponseModel.Output.Choices![0].Message.Content, text.ToString());
}
[Fact]
@@ -139,8 +139,7 @@ public async Task ChatClient_ImageRecognition_SuccessAsync()
await dashScopeClient.Received().GetMultimodalGenerationAsync(
Arg.Is>(m => m.IsEquivalent(testCase.RequestModel)),
Arg.Any());
- response.Messages[0].Text.Should()
- .BeEquivalentTo(testCase.ResponseModel.Output.Choices[0].Message.Content[0].Text);
+ Assert.Equal(testCase.ResponseModel.Output.Choices[0].Message.Content[0].Text, response.Messages[0].Text);
}
[Fact]
@@ -191,6 +190,6 @@ public async Task ChatClient_ImageRecognitionStream_SuccessAsync()
_ = dashScopeClient.Received().GetMultimodalGenerationStreamAsync(
Arg.Is>(m => m.IsEquivalent(testCase.RequestModel)),
Arg.Any());
- text.ToString().Should().Be(testCase.ResponseModel.Output.Choices.First().Message.Content[0].Text);
+ Assert.Equal(testCase.ResponseModel.Output.Choices.First().Message.Content[0].Text, text.ToString());
}
}
diff --git a/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj b/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj
index 4c729f0..293114c 100644
--- a/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj
+++ b/test/Cnblogs.DashScope.AI.UnitTests/Cnblogs.DashScope.AI.UnitTests.csproj
@@ -13,7 +13,6 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs b/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs
index f8bad1b..b8c17e6 100644
--- a/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs
+++ b/test/Cnblogs.DashScope.AI.UnitTests/EmbeddingClientTests.cs
@@ -1,6 +1,5 @@
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using Microsoft.Extensions.AI;
using NSubstitute;
using NSubstitute.Extensions;
@@ -34,10 +33,11 @@ public async Task EmbeddingClient_Text_SuccessAsync()
// Assert
_ = dashScopeClient.Received().GetEmbeddingsAsync(
- Arg.Is>(
- m => m.IsEquivalent(testCase.RequestModel)),
+ Arg.Is>(m
+ => m.IsEquivalent(testCase.RequestModel)),
Arg.Any());
- response.Select(x => x.Vector.ToArray()).Should()
- .BeEquivalentTo(testCase.ResponseModel.Output.Embeddings.Select(x => x.Embedding));
+ Assert.Equivalent(
+ testCase.ResponseModel.Output.Embeddings.Select(x => x.Embedding),
+ response.Select(x => x.Vector.ToArray()));
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs
index d6de7a6..6552149 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs
@@ -1,5 +1,4 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,7 +20,7 @@ public async Task SingleCompletion_TextNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -39,7 +38,7 @@ public async Task SingleCompletion_ThoughtNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -58,11 +57,17 @@ public async Task SingleCompletion_TextSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- outputs.SkipLast(1).Should().AllSatisfy(x => x.Output.FinishReason.Should().Be("null"));
- outputs.Last().Should().BeEquivalentTo(
- testCase.ResponseModel,
- o => o.Excluding(y => y.Output.Text).Excluding(x => x.Output.Thoughts));
- text.Should().Be(testCase.ResponseModel.Output.Text);
+ Assert.All(outputs.SkipLast(1), x => Assert.Equal("null", x.Output.FinishReason));
+ Assert.Equal(testCase.ResponseModel.Output.Text, text);
+ var last = outputs.Last();
+ last = last with
+ {
+ Output = last.Output with
+ {
+ Text = testCase.ResponseModel.Output.Text, Thoughts = testCase.ResponseModel.Output.Thoughts
+ }
+ };
+ Assert.Equivalent(testCase.ResponseModel, last);
}
[Fact]
@@ -80,7 +85,7 @@ public async Task ConversationCompletion_SessionIdNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -98,7 +103,7 @@ public async Task ConversationCompletion_MessageNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -116,7 +121,7 @@ public async Task SingleCompletion_MemoryNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -134,6 +139,6 @@ public async Task SingleCompletion_WorkflowNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs
index 91c44c4..14022b2 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/BackgroundGenerationSerializationTests.cs
@@ -1,5 +1,5 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,6 +21,6 @@ public async Task BackgroundGeneration_CreateTask_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj b/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj
index 3fbb8f0..2fd5793 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj
@@ -13,7 +13,6 @@
-
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs
index 7b3aab5..a2317bd 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs
@@ -1,12 +1,19 @@
using System.Net.Http.Headers;
using System.Reflection;
using Cnblogs.DashScope.Core;
-using FluentAssertions;
+using Xunit.Abstractions;
namespace Cnblogs.DashScope.Sdk.UnitTests;
public class DashScopeClientTests
{
+ private readonly ITestOutputHelper _output;
+
+ public DashScopeClientTests(ITestOutputHelper output)
+ {
+ _output = output;
+ }
+
[Fact]
public void DashScopeClient_Constructor_New()
{
@@ -14,10 +21,8 @@ public void DashScopeClient_Constructor_New()
const string apiKey = "apiKey";
// Act
- var act = () => new DashScopeClient(apiKey);
-
- // Assert
- act.Should().NotThrow();
+ var client = new DashScopeClient(apiKey);
+ _output.WriteLine("hash: " + client.GetHashCode()); // do something to avoid optimization
}
[Theory]
@@ -37,7 +42,7 @@ public void DashScopeClient_Constructor_NotCacheableParams(
var value2 = HttpClientAccessor.GetValue(client2);
// Assert
- value.Should().NotBe(value2);
+ Assert.NotSame(value2, value);
}
[Theory]
@@ -57,7 +62,7 @@ public void DashScopeClient_Constructor_CacheableParams(
var value2 = HttpClientAccessor.GetValue(client2);
// Assert
- value.Should().Be(value2);
+ Assert.Same(value2, value);
}
[Fact]
@@ -71,8 +76,7 @@ public void DashScopeClient_Constructor_WithApiKeyHeader()
var value = HttpClientAccessor.GetValue(client) as HttpClient;
// Assert
- value?.DefaultRequestHeaders.Authorization?.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", apiKey));
+ Assert.Equivalent(new AuthenticationHeaderValue("Bearer", apiKey), value?.DefaultRequestHeaders.Authorization);
}
[Fact]
@@ -87,7 +91,7 @@ public void DashScopeClient_Constructor_WithWorkspaceId()
var value = HttpClientAccessor.GetValue(client) as HttpClient;
// Assert
- value?.DefaultRequestHeaders.GetValues("X-DashScope-WorkSpace").Should().BeEquivalentTo(workspaceId);
+ Assert.Equal(workspaceId, value?.DefaultRequestHeaders.GetValues("X-DashScope-WorkSpace").First());
}
[Fact]
@@ -102,7 +106,7 @@ public void DashScopeClient_Constructor_WithPrivateEndpoint()
var value = HttpClientAccessor.GetValue(client) as HttpClient;
// Assert
- value?.BaseAddress.Should().BeEquivalentTo(new Uri(privateEndpoint));
+ Assert.Equivalent(new Uri(privateEndpoint), value?.BaseAddress);
}
public static TheoryData ParamsShouldNotCache
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs
index ba17907..3f3d9b5 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ErrorTests.cs
@@ -1,6 +1,5 @@
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using NSubstitute;
using NSubstitute.ExceptionExtensions;
using NSubstitute.Extensions;
@@ -21,7 +20,8 @@ public async Task Error_AuthError_ExceptionAsync()
var act = async () => await client.GetTextCompletionAsync(testCase.RequestModel);
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeEquivalentTo(testCase.ResponseModel);
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Equivalent(testCase.ResponseModel, ex.Error);
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
@@ -39,7 +39,8 @@ public async Task Error_ParameterErrorNoSse_ExceptionAsync()
var act = async () => await client.GetTextCompletionAsync(testCase.RequestModel);
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeEquivalentTo(testCase.ResponseModel);
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Equivalent(testCase.ResponseModel, ex.Error);
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
@@ -58,7 +59,8 @@ public async Task Error_ParameterErrorSse_ExceptionAsync()
var act = async () => await stream.LastAsync();
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeEquivalentTo(testCase.ResponseModel);
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Equivalent(testCase.ResponseModel, ex.Error);
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
@@ -71,13 +73,15 @@ public async Task Error_NetworkError_ExceptionAsync()
var (client, handler) = Sut.GetTestClient();
handler.Configure().MockSend(Arg.Any(), Arg.Any())
.Throws(new InvalidOperationException("Network error!"));
+ var testCase = Snapshots.TextGeneration.TextFormat.SinglePrompt;
// Act
var act = async ()
- => await client.GetTextCompletionAsync(Snapshots.TextGeneration.TextFormat.SinglePrompt.RequestModel);
+ => await client.GetTextCompletionAsync(testCase.RequestModel);
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeNull();
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Null(ex.Error);
}
[Fact]
@@ -94,6 +98,7 @@ public async Task Error_OpenAiCompatibleError_ExceptionAsync()
"other");
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeEquivalentTo(testCase.ResponseModel);
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Equivalent(testCase.ResponseModel, ex.Error);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs
index 9b92f25..5a9dac0 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/FileSerializationTests.cs
@@ -1,5 +1,5 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,7 +21,7 @@ public async Task File_Upload_SuccessAsync()
handler.Received().MockSend(
Arg.Is(r => r.RequestUri!.AbsolutePath == "/compatible-mode/v1/files"),
Arg.Any());
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -40,7 +40,7 @@ public async Task File_Get_SuccessAsync()
Arg.Is(
r => r.RequestUri!.AbsolutePath == "/compatible-mode/v1/files/" + testCase.ResponseModel.Id.Value),
Arg.Any());
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -55,7 +55,7 @@ public async Task File_List_SuccessAsync()
var list = await client.ListFilesAsync();
// Assert
- list.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, list);
}
[Fact]
@@ -74,6 +74,6 @@ public async Task File_Delete_SuccessAsync()
Arg.Is(
r => r.RequestUri!.AbsolutePath == "/compatible-mode/v1/files/" + testCase.ResponseModel.Id.Value),
Arg.Any());
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs
index 752e922..ac1b04b 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageGenerationSerializationTests.cs
@@ -1,5 +1,5 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,6 +21,6 @@ public async Task ImageGeneration_CreateTask_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs
index 47013e0..f6348ca 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ImageSynthesisSerializationTests.cs
@@ -1,5 +1,4 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,6 +20,6 @@ public async Task ImageSynThesis_CreateTask_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs
index 0170d0d..5825b14 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/MultimodalGenerationSerializationTests.cs
@@ -1,7 +1,6 @@
using System.Text;
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -25,7 +24,7 @@ public async Task MultimodalGeneration_NoSse_SuccessAsync(
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Theory]
@@ -41,18 +40,31 @@ public async Task MultimodalGeneration_Sse_SuccessAsync(
// Act
var message = new StringBuilder();
var outputs = await client.GetMultimodalGenerationStreamAsync(testCase.RequestModel).ToListAsync();
- outputs.ForEach(
- x => message.Append(x.Output.Choices[0].Message.Content.FirstOrDefault()?.Text ?? string.Empty));
+ outputs.ForEach(x
+ => message.Append(x.Output.Choices[0].Message.Content.FirstOrDefault()?.Text ?? string.Empty));
// Assert
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- outputs.SkipLast(1).Should().AllSatisfy(x => x.Output.Choices[0].FinishReason.Should().Be("null"));
- outputs.Last().Should().BeEquivalentTo(
- testCase.ResponseModel,
- o => o.Excluding(y => y.Output.Choices[0].Message.Content));
- message.ToString().Should().Be(testCase.ResponseModel.Output.Choices[0].Message.Content[0].Text);
+ Assert.All(outputs.SkipLast(1), x => Assert.Equal("null", x.Output.Choices[0].FinishReason));
+ Assert.Equal(testCase.ResponseModel.Output.Choices[0].Message.Content[0].Text, message.ToString());
+ var last = outputs.Last();
+ last = last with
+ {
+ Output = new MultimodalOutput(
+ new List
+ {
+ last.Output.Choices[0] with
+ {
+ Message = last.Output.Choices[0].Message with
+ {
+ Content = testCase.ResponseModel.Output.Choices[0].Message.Content
+ }
+ }
+ })
+ };
+ Assert.Equivalent(last, testCase.ResponseModel);
}
public static TheoryData,
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs
index 69f0192..ae7615d 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/QWenTokenizerTests.cs
@@ -1,5 +1,4 @@
using Cnblogs.DashScope.Core;
-using FluentAssertions;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -53,7 +52,7 @@ public void QWenTokenizer_Encode_SuccessAsync()
var embeddings = QWenTokenizer.Encode(Text);
// Assert
- embeddings.Should().BeEquivalentTo(Tokens);
+ Assert.Equivalent(Tokens, embeddings);
}
[Fact]
@@ -63,7 +62,7 @@ public void QWenTokenizer_Decode_SuccessAsync()
var text = QWenTokenizer.Decode(Tokens);
// Assert
- text.Should().BeEquivalentTo(Text);
+ Assert.Equal(Text, text);
}
[Fact]
@@ -73,6 +72,6 @@ public void QWenTokenizer_EncodeToStrings_SuccessAsync()
var tokens = QWenTokenizer.Tokenizer.Encode(Text);
// Assert
- tokens.Should().BeEquivalentTo(Tokens);
+ Assert.Equivalent(Tokens, tokens);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ServiceCollectionInjectorTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ServiceCollectionInjectorTests.cs
index 2d3ff04..54d6870 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ServiceCollectionInjectorTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ServiceCollectionInjectorTests.cs
@@ -1,7 +1,6 @@
using System.Net.Http.Headers;
using Cnblogs.DashScope.AspNetCore;
using Cnblogs.DashScope.Core;
-using FluentAssertions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@@ -23,13 +22,15 @@ public void Parameter_Normal_Inject()
var provider = services.BuildServiceProvider();
var httpClient = provider.GetRequiredService()
.CreateClient(DashScopeAspNetCoreDefaults.DefaultHttpClientName);
+ var client = provider.GetRequiredService();
// Assert
- provider.GetRequiredService().Should().NotBeNull().And
- .BeOfType();
- httpClient.Should().NotBeNull();
- httpClient.DefaultRequestHeaders.Authorization.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", ApiKey));
+ Assert.NotNull(client);
+ Assert.IsType(client);
+ Assert.NotNull(httpClient);
+ Assert.Equivalent(
+ new AuthenticationHeaderValue("Bearer", ApiKey),
+ httpClient.DefaultRequestHeaders.Authorization);
}
[Fact]
@@ -43,14 +44,16 @@ public void Parameter_HasProxy_Inject()
var provider = services.BuildServiceProvider();
var httpClient = provider.GetRequiredService()
.CreateClient(DashScopeAspNetCoreDefaults.DefaultHttpClientName);
+ var client = provider.GetRequiredService();
// Assert
- provider.GetRequiredService().Should().NotBeNull().And
- .BeOfType();
- httpClient.Should().NotBeNull();
- httpClient.DefaultRequestHeaders.Authorization.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", ApiKey));
- httpClient.BaseAddress.Should().BeEquivalentTo(new Uri(ProxyApi));
+ Assert.NotNull(client);
+ Assert.IsType(client);
+ Assert.NotNull(httpClient);
+ Assert.Equivalent(
+ new AuthenticationHeaderValue("Bearer", ApiKey),
+ httpClient.DefaultRequestHeaders.Authorization);
+ Assert.Equivalent(new Uri(ProxyApi), httpClient.BaseAddress);
}
[Fact]
@@ -71,14 +74,16 @@ public void Configuration_Normal_Inject()
var provider = services.BuildServiceProvider();
var httpClient = provider.GetRequiredService()
.CreateClient(DashScopeAspNetCoreDefaults.DefaultHttpClientName);
+ var client = provider.GetRequiredService();
// Assert
- provider.GetRequiredService().Should().NotBeNull().And
- .BeOfType();
- httpClient.Should().NotBeNull();
- httpClient.DefaultRequestHeaders.Authorization.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", ApiKey));
- httpClient.BaseAddress.Should().BeEquivalentTo(new Uri(ProxyApi));
+ Assert.NotNull(client);
+ Assert.IsType(client);
+ Assert.NotNull(httpClient);
+ Assert.Equivalent(
+ new AuthenticationHeaderValue("Bearer", ApiKey),
+ httpClient.DefaultRequestHeaders.Authorization);
+ Assert.Equivalent(new Uri(ProxyApi), httpClient.BaseAddress);
}
[Fact]
@@ -99,14 +104,16 @@ public void Configuration_CustomSectionName_Inject()
var provider = services.BuildServiceProvider();
var httpClient = provider.GetRequiredService()
.CreateClient(DashScopeAspNetCoreDefaults.DefaultHttpClientName);
+ var client = provider.GetRequiredService();
// Assert
- provider.GetRequiredService().Should().NotBeNull().And
- .BeOfType();
- httpClient.Should().NotBeNull();
- httpClient.DefaultRequestHeaders.Authorization.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", ApiKey));
- httpClient.BaseAddress.Should().BeEquivalentTo(new Uri(ProxyApi));
+ Assert.NotNull(client);
+ Assert.IsType(client);
+ Assert.NotNull(httpClient);
+ Assert.Equivalent(
+ new AuthenticationHeaderValue("Bearer", ApiKey),
+ httpClient.DefaultRequestHeaders.Authorization);
+ Assert.Equivalent(new Uri(ProxyApi), httpClient.BaseAddress);
}
[Fact]
@@ -121,14 +128,16 @@ public void Configuration_AddMultipleTime_Replace()
var provider = services.BuildServiceProvider();
var httpClient = provider.GetRequiredService()
.CreateClient(DashScopeAspNetCoreDefaults.DefaultHttpClientName);
+ var client = provider.GetRequiredService();
// Assert
- provider.GetRequiredService().Should().NotBeNull().And
- .BeOfType();
- httpClient.Should().NotBeNull();
- httpClient.DefaultRequestHeaders.Authorization.Should()
- .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", ApiKey));
- httpClient.BaseAddress.Should().BeEquivalentTo(new Uri(ProxyApi));
+ Assert.NotNull(client);
+ Assert.IsType(client);
+ Assert.NotNull(httpClient);
+ Assert.Equivalent(
+ new AuthenticationHeaderValue("Bearer", ApiKey),
+ httpClient.DefaultRequestHeaders.Authorization);
+ Assert.Equivalent(new Uri(ProxyApi), httpClient.BaseAddress);
}
[Fact]
@@ -143,6 +152,6 @@ public void Configuration_NoApiKey_Throw()
var act = () => services.AddDashScopeClient(configuration);
// Assert
- act.Should().Throw();
+ Assert.Throws(act);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs
index 745e9c5..f98005e 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TaskSerializationTests.cs
@@ -1,6 +1,5 @@
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -19,7 +18,7 @@ public async Task GetTask_Unknown_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -34,7 +33,8 @@ public async Task CancelTask_TaskAlreadyCompleted_FailAsync()
var act = async () => await client.CancelTaskAsync(Cases.Uuid);
// Assert
- (await act.Should().ThrowAsync()).And.Error.Should().BeEquivalentTo(testCase.ResponseModel);
+ var ex = await Assert.ThrowsAsync(act);
+ Assert.Equivalent(testCase.ResponseModel, ex.Error);
}
[Fact]
@@ -50,7 +50,7 @@ public async Task GetTask_BatchEmbeddings_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -66,7 +66,7 @@ public async Task GetTask_ImageSynthesis_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -82,7 +82,7 @@ public async Task GetTask_ImageGeneration_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -98,7 +98,7 @@ public async Task GetTask_BackgroundGeneration_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -114,7 +114,7 @@ public async Task GetTask_RunningTask_SuccessAsync()
testCase.ResponseModel.Output.TaskId);
// Assert
- task.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, task);
}
[Fact]
@@ -136,6 +136,6 @@ public async Task ListTasks_Tasks_SuccessAsync()
status: DashScopeTaskStatus.Succeeded);
// Assert
- tasks.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, tasks);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs
index 0b380ce..49c3553 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextEmbeddingSerializationTests.cs
@@ -1,5 +1,6 @@
-using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+using Cnblogs.DashScope.Core;
+using Cnblogs.DashScope.Tests.Shared.Utils;
+
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,10 +22,9 @@ public async Task TextEmbedding_MultipleTexts_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Output.Embeddings[0].Embedding.Should().NotBeEmpty(); // embedding array is too large
- response.Should().BeEquivalentTo(
- testCase.ResponseModel,
- o => o.Excluding(x => x.Output.Embeddings[0].Embedding));
+ Assert.NotEmpty(response.Output.Embeddings[0].Embedding); // embedding array is too large
+ response = response with { Output = new TextEmbeddingOutput(response.Output.Embeddings) };
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -42,6 +42,6 @@ public async Task BatchTextEmbedding_ReturnTask_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs
index edc0bf4..7eb5642 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationSerializationTests.cs
@@ -1,7 +1,6 @@
using System.Text;
using Cnblogs.DashScope.Core;
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -23,7 +22,7 @@ public async Task SingleCompletion_TextFormatNoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Fact]
@@ -43,9 +42,20 @@ public async Task SingleCompletion_TextFormatSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- outputs.SkipLast(1).Should().AllSatisfy(x => x.Output.FinishReason.Should().Be("null"));
- outputs.Last().Should().BeEquivalentTo(testCase.ResponseModel, o => o.Excluding(y => y.Output.Text));
- message.ToString().Should().Be(testCase.ResponseModel.Output.Text);
+ Assert.All(outputs.SkipLast(1), x => Assert.Equal("null", x.Output.FinishReason));
+ Assert.Equal(testCase.ResponseModel.Output.Text, message.ToString());
+ var last = outputs.Last();
+ last = last with
+ {
+ Output = new TextGenerationOutput()
+ {
+ Text = testCase.ResponseModel.Output.Text,
+ Choices = last.Output.Choices,
+ FinishReason = last.Output.FinishReason,
+ SearchInfo = last.Output.SearchInfo
+ }
+ };
+ Assert.Equivalent(testCase.ResponseModel, last);
}
[Theory]
@@ -65,7 +75,7 @@ public async Task SingleCompletion_MessageFormatNoSse_SuccessAsync(
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Theory]
@@ -83,25 +93,33 @@ public async Task SingleCompletion_MessageFormatSse_SuccessAsync(
var message = new StringBuilder();
var reasoning = new StringBuilder();
var outputs = await client.GetTextCompletionStreamAsync(testCase.RequestModel).ToListAsync();
- outputs.ForEach(
- x =>
- {
- message.Append(x.Output.Choices![0].Message.Content);
- reasoning.Append(x.Output.Choices![0].Message.ReasoningContent ?? string.Empty);
- });
+ outputs.ForEach(x =>
+ {
+ message.Append(x.Output.Choices![0].Message.Content);
+ reasoning.Append(x.Output.Choices![0].Message.ReasoningContent ?? string.Empty);
+ });
// Assert
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- outputs.SkipLast(1).Should().AllSatisfy(x => x.Output.Choices![0].FinishReason.Should().Be("null"));
- outputs.Last().Should().BeEquivalentTo(
- testCase.ResponseModel,
- o => o.Excluding(y => y.Output.Choices![0].Message.Content)
- .Excluding(y => y.Output.Choices![0].Message.ReasoningContent));
- message.ToString().Should().Be(testCase.ResponseModel.Output.Choices![0].Message.Content);
- reasoning.ToString().Should()
- .Be(testCase.ResponseModel.Output.Choices![0].Message.ReasoningContent ?? string.Empty);
+ Assert.All(outputs.SkipLast(1), x => Assert.Equal("null", x.Output.Choices![0].FinishReason));
+ Assert.Equal(testCase.ResponseModel.Output.Choices![0].Message.Content, message.ToString());
+ Assert.Equal(
+ testCase.ResponseModel.Output.Choices![0].Message.ReasoningContent ?? string.Empty,
+ reasoning.ToString());
+ var last = outputs.Last();
+ last.Output.Choices = new List
+ {
+ new()
+ {
+ Message = last.Output.Choices![0].Message with
+ {
+ Content = testCase.ResponseModel.Output.Choices[0].Message.Content,
+ ReasoningContent = testCase.ResponseModel.Output.Choices[0].Message.ReasoningContent
+ }
+ }
+ };
}
[Theory]
@@ -121,7 +139,7 @@ public async Task ConversationCompletion_MessageFormatNoSse_SuccessAsync(
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
[Theory]
@@ -143,11 +161,12 @@ public async Task ConversationCompletion_MessageFormatSse_SuccessAsync(
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- outputs.SkipLast(1).Should().AllSatisfy(x => x.Output.Choices![0].FinishReason.Should().Be("null"));
- outputs.Last().Should().BeEquivalentTo(
- testCase.ResponseModel,
- o => o.Excluding(y => y.Output.Choices![0].Message.Content));
- message.ToString().Should().Be(testCase.ResponseModel.Output.Choices![0].Message.Content);
+ Assert.All(outputs.SkipLast(1), x => Assert.Equal("null", x.Output.Choices![0].FinishReason));
+ Assert.Equal(testCase.ResponseModel.Output.Choices![0].Message.Content, message.ToString());
+ var last = outputs.Last();
+ last.Output.Choices![0].Message =
+ TextChatMessage.Assistant(testCase.ResponseModel.Output.Choices[0].Message.Content);
+ Assert.Equivalent(testCase.ResponseModel, last);
}
public static readonly TheoryData,
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs
index e269682..6afe6c5 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TextGenerationStopConverterTests.cs
@@ -1,6 +1,5 @@
using System.Text.Json;
using Cnblogs.DashScope.Core;
-using FluentAssertions;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -20,7 +19,7 @@ public void TextGenerationStopConvertor_Serialize_Success(TextGenerationStop? st
var actual = JsonSerializer.Serialize(obj, SerializerOptions);
// Assert
- actual.Should().Be(json);
+ Assert.Equal(json, actual);
}
[Theory]
@@ -31,7 +30,7 @@ public void TextGenerationStopConvertor_Deserialize_Success(TextGenerationStop?
var obj = JsonSerializer.Deserialize(json, SerializerOptions);
// Assert
- obj.Should().BeEquivalentTo(new TestObj(stop));
+ Assert.Equivalent(new TestObj(stop), obj);
}
[Theory]
@@ -42,7 +41,7 @@ public void TextGenerationStopConvertor_InvalidJson_Exception(string json)
var act = () => JsonSerializer.Deserialize(json, SerializerOptions);
// Assert
- act.Should().Throw();
+ Assert.Throws(act);
}
public record TestObj(TextGenerationStop? Stop);
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs
index 6c3a49b..c57e3c2 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/TokenizationSerializationTests.cs
@@ -1,5 +1,5 @@
using Cnblogs.DashScope.Tests.Shared.Utils;
-using FluentAssertions;
+
using NSubstitute;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -21,6 +21,6 @@ public async Task Tokenization_NoSse_SuccessAsync()
handler.Received().MockSend(
Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))),
Arg.Any());
- response.Should().BeEquivalentTo(testCase.ResponseModel);
+ Assert.Equivalent(testCase.ResponseModel, response);
}
}
diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs
index c9a23c7..f260c35 100644
--- a/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs
+++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ToolChoiceJsonConverterTests.cs
@@ -1,6 +1,5 @@
using System.Text.Json;
using Cnblogs.DashScope.Core;
-using FluentAssertions;
namespace Cnblogs.DashScope.Sdk.UnitTests;
@@ -20,7 +19,7 @@ public void TextGenerationStopConvertor_Serialize_Success(ToolChoice? choice, st
var actual = JsonSerializer.Serialize(obj, SerializerOptions);
// Assert
- actual.Should().Be(json);
+ Assert.Equal(json, actual);
}
[Theory]
@@ -31,7 +30,7 @@ public void TextGenerationStopConvertor_Deserialize_Success(ToolChoice? choice,
var obj = JsonSerializer.Deserialize(json, SerializerOptions);
// Assert
- obj.Should().BeEquivalentTo(new TestObj(choice));
+ Assert.Equivalent(new TestObj(choice), obj);
}
[Theory]
@@ -42,7 +41,7 @@ public void TextGenerationStopConvertor_InvalidJson_Exception(string json)
var act = () => JsonSerializer.Deserialize(json, SerializerOptions);
// Assert
- act.Should().Throw();
+ Assert.Throws(act);
}
public record TestObj(ToolChoice? Choice);
diff --git a/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj b/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj
index ab1aa6b..0f05683 100644
--- a/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj
+++ b/test/Cnblogs.DashScope.Tests.Shared/Cnblogs.DashScope.Tests.Shared.csproj
@@ -8,10 +8,10 @@
-
+
diff --git a/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs b/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs
index c643ab3..d64ead5 100644
--- a/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs
+++ b/test/Cnblogs.DashScope.Tests.Shared/Utils/EquivalentUtils.cs
@@ -1,4 +1,4 @@
-using FluentAssertions;
+using Xunit;
namespace Cnblogs.DashScope.Tests.Shared.Utils;
@@ -8,7 +8,7 @@ public static bool IsEquivalent(this T left, T right)
{
try
{
- left.Should().BeEquivalentTo(right);
+ Assert.Equivalent(right, left);
}
catch (Exception)
{