diff --git a/README.md b/README.md index efd74b1..c635192 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ public class YourService(IDashScopeClient client) - Image Generation - `CreateWanxImageGenerationTaskAsync()` and `GetWanxImageGenerationTaskAsync()` - Background Image Generation - `CreateWanxBackgroundGenerationTaskAsync()` and `GetWanxBackgroundGenerationTaskAsync()` - File API that used by Qwen-Long - `dashScopeClient.UploadFileAsync()` and `dashScopeClient.DeleteFileAsync` +- Application call - `GetApplicationResponseAsync()` and `GetApplicationResponseStreamAsync()` # Examples @@ -208,3 +209,71 @@ Delete file if needed ```csharp var deletionResult = await dashScopeClient.DeleteFileAsync(uploadedFile.Id); ``` + +## Application call + +Use `GetApplicationResponseAsync` to call an application. + +Use `GetApplicationResponseStreamAsync` for streaming output. + +```csharp +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() { Prompt = "Summarize this file." }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["thie5bysoj"], + FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + } + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` + +`ApplicationRequest` use an `Dictionary` as `BizParams` by default. + +```csharp +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Prompt = "Summarize this file.", + BizParams = new Dictionary() + { + { "customKey1", "custom-value" } + } + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` + +You can use the generic version `ApplicationRequest` for strong-typed `BizParams`. But keep in mind that client use `snake_case` by default when doing json serialization, you may need to use `[JsonPropertyName("camelCase")]` for other type of naming policy. + +```csharp +public record TestApplicationBizParam( + [property: JsonPropertyName("sourceCode")] + string SourceCode); + +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Prompt = "Summarize this file.", + BizParams = new TestApplicationBizParam("test") + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` + diff --git a/README.zh-Hans.md b/README.zh-Hans.md index 9f81d6b..a84421d 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -76,6 +76,7 @@ public class YourService(IDashScopeClient client) - 人像风格重绘 - `CreateWanxImageGenerationTaskAsync()` and `GetWanxImageGenerationTaskAsync()` - 图像背景生成 - `CreateWanxBackgroundGenerationTaskAsync()` and `GetWanxBackgroundGenerationTaskAsync()` - 适用于 QWen-Long 的文件 API `dashScopeClient.UploadFileAsync()` and `dashScopeClient.DeleteFileAsync` +- 应用调用 `dashScopeClient.GetApplicationResponseAsync` 和 `dashScopeClient.GetApplicationResponseStreamAsync()` - 其他使用相同 Endpoint 的模型 # 示例 @@ -204,3 +205,71 @@ Console.WriteLine(completion.Output.Choices[0].Message.Content); ```csharp var deletionResult = await dashScopeClient.DeleteFileAsync(uploadedFile.Id); ``` + +## 应用调用 + +`GetApplicationResponseAsync` 用于进行应用调用。 + +`GetApplicationResponseStreamAsync` 用于流式调用。 + +```csharp +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() { Prompt = "Summarize this file." }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["thie5bysoj"], + FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + } + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` + +`ApplicationRequest` 默认使用 `Dictionary` 作为 `BizParams` 的类型。 + +```csharp +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Prompt = "Summarize this file.", + BizParams = new Dictionary() + { + { "customKey1", "custom-value" } + } + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` + +如需强类型支持,可以使用泛型类 `ApplicationRequest`。 +注意 SDK 在 JSON 序列化时使用 `snake_case`。如果你的应用采用其他的命名规则,请使用 `[JsonPropertyName("camelCase")]` 来手动指定序列化时的属性名称。 + +```csharp +public record TestApplicationBizParam( + [property: JsonPropertyName("sourceCode")] + string SourceCode); + +var request = + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Prompt = "Summarize this file.", + BizParams = new TestApplicationBizParam("test") + } + }; +var response = await client.GetApplicationResponseAsync("your-application-id", request); +Console.WriteLine(response.Output.Text); +``` diff --git a/src/Cnblogs.DashScope.AspNetCore/ServiceCollectionInjector.cs b/src/Cnblogs.DashScope.AspNetCore/ServiceCollectionInjector.cs index 6d91b83..ee6b00a 100644 --- a/src/Cnblogs.DashScope.AspNetCore/ServiceCollectionInjector.cs +++ b/src/Cnblogs.DashScope.AspNetCore/ServiceCollectionInjector.cs @@ -38,9 +38,8 @@ public static IHttpClientBuilder AddDashScopeClient(this IServiceCollection serv var apiKey = section["apiKey"] ?? throw new InvalidOperationException("There is no apiKey provided in given section"); var baseAddress = section["baseAddress"]; - return string.IsNullOrEmpty(baseAddress) - ? services.AddDashScopeClient(apiKey) - : services.AddDashScopeClient(apiKey, baseAddress); + var workspaceId = section["workspaceId"]; + return services.AddDashScopeClient(apiKey, baseAddress, workspaceId); } /// @@ -49,16 +48,24 @@ public static IHttpClientBuilder AddDashScopeClient(this IServiceCollection serv /// The service collection to add service to. /// The DashScope api key. /// The DashScope api base address, you may change this value if you are using proxy. + /// Default workspace id to use. /// public static IHttpClientBuilder AddDashScopeClient( this IServiceCollection services, string apiKey, - string baseAddress = "https://dashscope.aliyuncs.com/api/v1/") + string? baseAddress = null, + string? workspaceId = null) { + baseAddress ??= "https://dashscope.aliyuncs.com/api/v1/"; return services.AddHttpClient( h => { h.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); + if (string.IsNullOrWhiteSpace(workspaceId) == false) + { + h.DefaultRequestHeaders.Add("X-DashScope-WorkSpace", workspaceId); + } + h.BaseAddress = new Uri(baseAddress); }); } diff --git a/src/Cnblogs.DashScope.Core/ApplicationDocReference.cs b/src/Cnblogs.DashScope.Core/ApplicationDocReference.cs new file mode 100644 index 0000000..83c48af --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationDocReference.cs @@ -0,0 +1,20 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// One reference for application output. +/// +/// The index id of the doc. +/// Text slice title. +/// Unique id of the doc been referenced. +/// Name of the doc been referenced. +/// Referenced content. +/// Image URLs beed referenced. +/// Page numbers of referenced content belongs to. +public record ApplicationDocReference( + string IndexId, + string Title, + string DocId, + string DocName, + string Text, + List? Images, + List? PageNumber); diff --git a/src/Cnblogs.DashScope.Core/ApplicationInput.cs b/src/Cnblogs.DashScope.Core/ApplicationInput.cs new file mode 100644 index 0000000..965124b --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationInput.cs @@ -0,0 +1,47 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Inputs for application call. +/// +/// Type of the BizContent. +public class ApplicationInput + where TBizParams : class +{ + /// + /// The prompt for model to generate response upon. Optional when has been set. + /// + /// + /// Prompt will be appended to when both set. + /// + public string? Prompt { get; set; } + + /// + /// The session id for conversation history. This will be ignored if has been set. + /// + public string? SessionId { get; set; } + + /// + /// The conversation history. + /// + public IEnumerable? Messages { get; set; } + + /// + /// The id of memory when enabled. + /// + public string? MemoryId { get; set; } + + /// + /// List of image urls for inputs. + /// + public IEnumerable? ImageList { get; set; } + + /// + /// User defined content. + /// + public TBizParams? BizParams { get; set; } = null; +} + +/// +/// Inputs for application call. +/// +public class ApplicationInput : ApplicationInput>; diff --git a/src/Cnblogs.DashScope.Core/ApplicationMessage.cs b/src/Cnblogs.DashScope.Core/ApplicationMessage.cs new file mode 100644 index 0000000..9edfdf5 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationMessage.cs @@ -0,0 +1,30 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// A single message for application call. +/// +/// The role of this message belongs to. +/// The content of the message. +public record ApplicationMessage(string Role, string Content) +{ + /// + /// Creates a user message. + /// + /// Content of the message. + /// + public static ApplicationMessage User(string content) => new("user", content); + + /// + /// Creates a system message. + /// + /// Content of the message. + /// + public static ApplicationMessage System(string content) => new("system", content); + + /// + /// Creates a assistant message. + /// + /// Content of the message. + /// + public static ApplicationMessage Assistant(string content) => new("assistant", content); +} diff --git a/src/Cnblogs.DashScope.Core/ApplicationModelUsage.cs b/src/Cnblogs.DashScope.Core/ApplicationModelUsage.cs new file mode 100644 index 0000000..e0e838e --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationModelUsage.cs @@ -0,0 +1,9 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Token usages for one model. +/// +/// The id of the model. +/// Total input tokens of this model. +/// Total output tokens from this model. +public record ApplicationModelUsage(string ModelId, int InputTokens, int OutputTokens); diff --git a/src/Cnblogs.DashScope.Core/ApplicationOutput.cs b/src/Cnblogs.DashScope.Core/ApplicationOutput.cs new file mode 100644 index 0000000..258bd60 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationOutput.cs @@ -0,0 +1,16 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// The output of application call. +/// +/// Output text from application. +/// Finish reason from application. +/// Unique id of current session. +/// Thoughts from application. +/// Doc references from application output. +public record ApplicationOutput( + string Text, + string FinishReason, + string SessionId, + List? Thoughts, + List? DocReferences); diff --git a/src/Cnblogs.DashScope.Core/ApplicationOutputThought.cs b/src/Cnblogs.DashScope.Core/ApplicationOutputThought.cs new file mode 100644 index 0000000..b4bf55f --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationOutputThought.cs @@ -0,0 +1,24 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// The model thought output. +/// +/// The thought content of the model. +/// Type of the action. e.g. agentRag, reasoning. +/// The name of the action. +/// The action been executed. +/// The streaming result of action input. +/// The input of the action. +/// Lookup or plugin output. +/// Reasoning output when using DeepSeek-R1. +/// Arguments of the action. +public record ApplicationOutputThought( + string? Thought, + string? ActionType, + string? ActionName, + string? Action, + string? ActionInputStream, + string? ActionInput, + string? Observation, + string? Response, + string? Arguments); diff --git a/src/Cnblogs.DashScope.Core/ApplicationParameters.cs b/src/Cnblogs.DashScope.Core/ApplicationParameters.cs new file mode 100644 index 0000000..86303b0 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationParameters.cs @@ -0,0 +1,37 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Parameters for application call. +/// +public class ApplicationParameters : IIncrementalOutputParameter, ISeedParameter, IProbabilityParameter +{ + /// + public bool? IncrementalOutput { get; set; } + + /// + /// Output format for flow application. Can be full_thoughts or agent_format. Defaults to full_thoughts. + /// + public string? FlowStreamMode { get; set; } + + /// + /// Options for RAG applications. + /// + public ApplicationRagOptions? RagOptions { get; set; } + + /// + public ulong? Seed { get; set; } + + /// + public float? TopP { get; set; } + + /// + public int? TopK { get; set; } + + /// + public float? Temperature { get; set; } + + /// + /// Controls whether output contains think block. + /// + public bool? HasThoughts { get; set; } +} diff --git a/src/Cnblogs.DashScope.Core/ApplicationRagOptions.cs b/src/Cnblogs.DashScope.Core/ApplicationRagOptions.cs new file mode 100644 index 0000000..38aff36 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationRagOptions.cs @@ -0,0 +1,37 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Options for RAG application. +/// +public class ApplicationRagOptions +{ + /// + /// The pipelines to search from. + /// + public IEnumerable? PipelineIds { get; set; } + + /// + /// The ids of file to reference from. + /// + public IEnumerable? FileIds { get; set; } + + /// + /// Metadata filter for non-structured files. + /// + public Dictionary? MetadataFilter { get; set; } + + /// + /// Tag filter for non-structured files. + /// + public IEnumerable? Tags { get; set; } + + /// + /// Filter for structured files. + /// + public Dictionary? StructuredFilter { get; set; } + + /// + /// File ids for current session. + /// + public IEnumerable? SessionFileIds { get; set; } +} diff --git a/src/Cnblogs.DashScope.Core/ApplicationRequest.cs b/src/Cnblogs.DashScope.Core/ApplicationRequest.cs new file mode 100644 index 0000000..ca67ff4 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationRequest.cs @@ -0,0 +1,24 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Request body for an application all. +/// +/// Type of the biz_content +public class ApplicationRequest + where TBizParams : class +{ + /// + /// Content of this call. + /// + public required ApplicationInput Input { get; init; } + + /// + /// Optional configurations. + /// + public required ApplicationParameters? Parameters { get; init; } +} + +/// +/// Request body for an application call with dictionary biz_content. +/// +public class ApplicationRequest : ApplicationRequest>; diff --git a/src/Cnblogs.DashScope.Core/ApplicationResponse.cs b/src/Cnblogs.DashScope.Core/ApplicationResponse.cs new file mode 100644 index 0000000..2089940 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationResponse.cs @@ -0,0 +1,12 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Response of application call. +/// +/// Unique id of this request. +/// The output of application call. +/// Token usage of this application call. +public record ApplicationResponse( + string RequestId, + ApplicationOutput Output, + ApplicationUsage Usage); diff --git a/src/Cnblogs.DashScope.Core/ApplicationUsage.cs b/src/Cnblogs.DashScope.Core/ApplicationUsage.cs new file mode 100644 index 0000000..8a4ef98 --- /dev/null +++ b/src/Cnblogs.DashScope.Core/ApplicationUsage.cs @@ -0,0 +1,7 @@ +namespace Cnblogs.DashScope.Core; + +/// +/// Total token usages of this application call. +/// +/// All models been used and their token usages. Can be null when workflow application without using any model. +public record ApplicationUsage(List? Models); diff --git a/src/Cnblogs.DashScope.Core/DashScopeClient.cs b/src/Cnblogs.DashScope.Core/DashScopeClient.cs index 26f716f..dea20f9 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeClient.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeClient.cs @@ -15,32 +15,43 @@ public class DashScopeClient : DashScopeClientCore /// /// The DashScope api key. /// The timeout for internal http client, defaults to 2 minute. + /// The base address for dashscope api call. + /// The workspace id. /// - /// The underlying httpclient is cached by apiKey and timeout. - /// Client created with same apiKey and timeout value will share same underlying instance. + /// The underlying httpclient is cached by constructor parameter list. + /// Client created with same parameter value will share same underlying instance. /// - public DashScopeClient(string apiKey, TimeSpan? timeout = null) - : base(GetConfiguredClient(apiKey, timeout)) + public DashScopeClient( + string apiKey, + TimeSpan? timeout = null, + string? baseAddress = null, + string? workspaceId = null) + : base(GetConfiguredClient(apiKey, timeout, baseAddress, workspaceId)) { } - private static HttpClient GetConfiguredClient(string apiKey, TimeSpan? timeout) + private static HttpClient GetConfiguredClient( + string apiKey, + TimeSpan? timeout = null, + string? baseAddress = null, + string? workspaceId = null) { var client = ClientPools.GetValueOrDefault(GetCacheKey()); if (client is null) { client = new HttpClient { - BaseAddress = new Uri(DashScopeDefaults.DashScopeApiBaseAddress), + BaseAddress = new Uri(baseAddress ?? DashScopeDefaults.DashScopeApiBaseAddress), Timeout = timeout ?? TimeSpan.FromMinutes(2) }; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); + client.DefaultRequestHeaders.Add("X-DashScope-WorkSpace", workspaceId); ClientPools.Add(GetCacheKey(), client); } return client; - string GetCacheKey() => $"{apiKey}-{timeout?.TotalMilliseconds}"; + string GetCacheKey() => $"{apiKey}-{timeout?.TotalMilliseconds}-{baseAddress}-{workspaceId}"; } } diff --git a/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs b/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs index 9784516..9b917d0 100644 --- a/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs +++ b/src/Cnblogs.DashScope.Core/DashScopeClientCore.cs @@ -35,6 +35,46 @@ public DashScopeClientCore(HttpClient httpClient) /// public Uri? BaseAddress => _httpClient.BaseAddress; + /// + public Task GetApplicationResponseAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + { + return GetApplicationResponseAsync>(applicationId, input, cancellationToken); + } + + /// + public async Task GetApplicationResponseAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + where TBizContent : class + { + var request = BuildRequest(HttpMethod.Post, ApiLinks.Application(applicationId), input); + return (await SendAsync(request, cancellationToken))!; + } + + /// + public IAsyncEnumerable GetApplicationResponseStreamAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + { + return GetApplicationResponseStreamAsync>(applicationId, input, cancellationToken); + } + + /// + public IAsyncEnumerable GetApplicationResponseStreamAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + where TBizContent : class + { + var request = BuildSseRequest(HttpMethod.Post, ApiLinks.Application(applicationId), input); + return StreamAsync(request, cancellationToken); + } + /// public async Task> GetTextCompletionAsync( ModelRequest input, @@ -257,7 +297,8 @@ private static HttpRequestMessage BuildRequest( string url, TPayload? payload = null, bool sse = false, - bool isTask = false) + bool isTask = false, + string? workspaceId = null) where TPayload : class { var message = new HttpRequestMessage(method, url) @@ -275,6 +316,11 @@ private static HttpRequestMessage BuildRequest( message.Headers.Add("X-DashScope-Async", "enable"); } + if (string.IsNullOrWhiteSpace(workspaceId) == false) + { + message.Headers.Add("X-DashScope-WorkspaceId", workspaceId); + } + return message; } diff --git a/src/Cnblogs.DashScope.Core/IDashScopeClient.cs b/src/Cnblogs.DashScope.Core/IDashScopeClient.cs index 3c32291..a123050 100644 --- a/src/Cnblogs.DashScope.Core/IDashScopeClient.cs +++ b/src/Cnblogs.DashScope.Core/IDashScopeClient.cs @@ -10,6 +10,58 @@ public interface IDashScopeClient /// Uri? BaseAddress { get; } + /// + /// Make a call to custom application. + /// + /// Name of the application. + /// The request body. + /// The cancellation token to use. + /// + Task GetApplicationResponseAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default); + + /// + /// Make a call to custom application. + /// + /// Name of the application. + /// The request body. + /// The cancellation token to use. + /// Type of the biz_content. + /// + Task GetApplicationResponseAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + where TBizParams : class; + + /// + /// Make a call to custom application. + /// + /// Name of the application. + /// The request body. + /// The cancellation token to use. + /// + IAsyncEnumerable GetApplicationResponseStreamAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default); + + /// + /// Make a call to custom application. + /// + /// Name of the application. + /// The request body. + /// The cancellation token to use. + /// Type of the biz_content. + /// + IAsyncEnumerable GetApplicationResponseStreamAsync( + string applicationId, + ApplicationRequest input, + CancellationToken cancellationToken = default) + where TBizContent : class; + /// /// Return textual completions as configured for a given prompt. /// diff --git a/src/Cnblogs.DashScope.Core/Internals/ApiLinks.cs b/src/Cnblogs.DashScope.Core/Internals/ApiLinks.cs index 22cc689..d098719 100644 --- a/src/Cnblogs.DashScope.Core/Internals/ApiLinks.cs +++ b/src/Cnblogs.DashScope.Core/Internals/ApiLinks.cs @@ -11,4 +11,5 @@ internal static class ApiLinks public const string Tasks = "tasks/"; public const string Tokenizer = "tokenizer"; public const string Files = "/compatible-mode/v1/files"; + public static string Application(string applicationId) => $"apps/{applicationId}/completion"; } diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs new file mode 100644 index 0000000..a8021a0 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/ApplicationSerializationTests.cs @@ -0,0 +1,139 @@ +using Cnblogs.DashScope.Sdk.UnitTests.Utils; +using FluentAssertions; +using NSubstitute; + +namespace Cnblogs.DashScope.Sdk.UnitTests; + +public class ApplicationSerializationTests +{ + [Fact] + public async Task SingleCompletion_TextNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.SinglePromptNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } + + [Fact] + public async Task SingleCompletion_ThoughtNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.SinglePromptWithThoughtsNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } + + [Fact] + public async Task SingleCompletion_TextSse_SuccessAsync() + { + // Arrange + const bool sse = true; + var testCase = Snapshots.Application.SinglePromptSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var outputs = await client.GetApplicationResponseStreamAsync("anyId", testCase.RequestModel).ToListAsync(); + var text = string.Join(string.Empty, outputs.Select(o => o.Output.Text)); + + // Assert + 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); + } + + [Fact] + public async Task ConversationCompletion_SessionIdNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.ConversationSessionIdNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } + + [Fact] + public async Task ConversationCompletion_MessageNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.ConversationMessageNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } + + [Fact] + public async Task SingleCompletion_MemoryNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.SinglePromptWithMemoryNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } + + [Fact] + public async Task SingleCompletion_WorkflowNoSse_SuccessAsync() + { + // Arrange + const bool sse = false; + var testCase = Snapshots.Application.WorkflowNoSse; + var (client, handler) = await Sut.GetTestClientAsync(sse, testCase); + + // Act + var response = await client.GetApplicationResponseAsync("anyId", testCase.RequestModel); + + // Assert + handler.Received().MockSend( + Arg.Is(m => Checkers.IsJsonEquivalent(m.Content!, testCase.GetRequestJson(sse))), + Arg.Any()); + response.Should().BeEquivalentTo(testCase.ResponseModel); + } +} 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 0c74f01..3f82c79 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Cnblogs.DashScope.Sdk.UnitTests.csproj @@ -10,8 +10,8 @@ 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 be60571..93f7d4d 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/DashScopeClientTests.cs @@ -75,6 +75,36 @@ public void DashScopeClient_Constructor_WithApiKeyHeader() .BeEquivalentTo(new AuthenticationHeaderValue("Bearer", apiKey)); } + [Fact] + public void DashScopeClient_Constructor_WithWorkspaceId() + { + // Arrange + const string apiKey = "key"; + const string workspaceId = "workspaceId"; + var client = new DashScopeClient(apiKey, null, null, workspaceId); + + // Act + var value = HttpClientAccessor.GetValue(client) as HttpClient; + + // Assert + value?.DefaultRequestHeaders.GetValues("X-DashScope-WorkSpace").Should().BeEquivalentTo(workspaceId); + } + + [Fact] + public void DashScopeClient_Constructor_WithPrivateEndpoint() + { + // Arrange + const string apiKey = "key"; + const string privateEndpoint = "https://dashscope.cnblogs.com/api/v1"; + var client = new DashScopeClient(apiKey, null, privateEndpoint); + + // Act + var value = HttpClientAccessor.GetValue(client) as HttpClient; + + // Assert + value?.BaseAddress.Should().BeEquivalentTo(new Uri(privateEndpoint)); + } + public static TheoryData ParamsShouldNotCache => new() { diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.body.json new file mode 100644 index 0000000..f553890 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.body.json @@ -0,0 +1,35 @@ +{ + "input": { + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant." + }, + { + "role": "user", + "content": "你是谁?" + }, + { + "role": "assistant", + "content": "我是阿里云开发的大规模语言模型,我叫通义千问。" + }, + { + "role": "user", + "content": "哪些人的主食偏好是米饭?" + } + ] + }, + "parameters": { + "has_thoughts": true, + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85, + "rag_options": { + "pipeline_ids": ["e6md69132k"], + "structured_filter": { + "年龄": 14 + } + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.header.txt new file mode 100644 index 0000000..cdf4d96 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/5ccc140108fd4b2ea5e6101fbada7583/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 914 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.body.txt new file mode 100644 index 0000000..2c53618 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"thoughts":[{"action_input_stream":"{}","action_type":"agentRag","observation":"[{\"content\":\"【文档名】:用户食物偏好\\n名字:小明\\n主食偏好:面食\\n年龄:14\\n\",\"dataId\":\"table_df4b06e8931545b4b0a65e011087c197_10207234_1\",\"dataName\":\"用户食物偏好\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_e6md69132k_table_df4b06e8931545b4b0a65e011087c197_10207234_1\",\"referenceIndex\":1,\"score\":0.2185690850019455,\"webSearch\":false}]","action_name":"知识检索","action":"rag","arguments":"{}"},{"action_input_stream":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"哪些人的主食偏好是米饭?\"}","action_type":"api","observation":"[]","action_name":"长期记忆检索","action":"memory","arguments":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"哪些人的主食偏好是米饭?\"}"}],"finish_reason":"stop","session_id":"9e2cf8c81f9a4fbe900a1f04b8522244","text":"米饭作为主食,深受许多国家和地区人们的喜爱。以下是一些以米饭为主食的群体:\n\n1. **中国人**:尤其在南方地区,米饭是大多数家庭的主要食物。从广东、福建到四川、云南,米饭搭配各种菜肴构成了日常饮食的重要部分。\n\n2. **日本人**:日本料理中,白米饭占据核心地位,无论是便当中的小碗饭还是寿司的基础,都体现了米饭在日本饮食文化中的重要性。\n\n3. **韩国人**:韩国家庭餐桌上的“石锅拌饭”、“紫菜包饭”等经典菜品,反映了米饭在韩国饮食习惯里的不可或缺。\n\n4. **东南亚各国居民**(如泰国、越南、菲律宾、印尼等):这些地区的传统美食几乎都离不开米饭,像泰国香米更是闻名全球,成为该国饮食文化的象征之一。\n\n5. **印度及南亚次大陆部分地区人群**:虽然面饼(Roti/Naan)也很受欢迎,但米饭特别是与咖喱一起食用时,同样是众多印度家庭及其他南亚国家(如孟加拉国、斯里兰卡等)的重要主食选择。\n\n6. **中东部分国家的人们**:尽管面包可能是更普遍的选择,但在一些特定场合或日常饮食中,例如搭配烤肉、炖菜时,米饭同样被广泛使用。\n\n总体而言,由于其易于种植、营养丰富且能够很好地与其他食材结合的特点,米饭成为了上述地区人们世代相传的主要食物来源之一。"},"usage":{"models":[{"output_tokens":311,"model_id":"qwen-plus","input_tokens":344}]},"request_id":"d42335b3-fcb2-9d11-b651-29562ac02abe"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.header.txt new file mode 100644 index 0000000..61085a5 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-message-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: d42335b3-fcb2-9d11-b651-29562ac02abe +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 8647 +req-arrive-time: 1742127970039 +resp-start-time: 1742127978686 +x-envoy-upstream-service-time: 8640 +content-encoding: gzip +date: Sun, 16 Mar 2025 12:26:18 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json new file mode 100644 index 0000000..2d07b49 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.body.json @@ -0,0 +1,19 @@ +{ + "input": { + "prompt": "总结一下第一本书的内容", + "session_id": "9995da2046a04b448dc5a562563f4835" + }, + "parameters": { + "has_thoughts": true, + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85, + "rag_options": { + "pipeline_ids": ["ll6yfcnxjg"], + "metadata_filter": { + "docType": "电子书" + } + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt new file mode 100644 index 0000000..55827d8 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/010aa085cc9943268731861c9511bb0c/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 471 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt new file mode 100644 index 0000000..7148a90 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"thoughts":[{"action_input_stream":"{}","action_type":"agentRag","observation":"[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Refactoring a Test...xlvPARTI.The Narratives····.1Chapter 1. A Brief Tour3About This Chapter3The Simplest Test Automation Strategy ThatCould Possibly Work3Development Process4Customer Tests5Unit Tests . . .Design for TestabilityTest Organization···What's Next?Chapter 2. Test Smells . . ..·····9About This Chapter9An Introduction to Test Smells..9What's a Test Smell? . . ...10Kinds of Test Smells ...10What to Do about Smells?..11A Catalog of Smells·...12The Project Smells...12The Behavior Smells. . ...13The Code Smells..16What's Next?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_27\",\"images\":[],\"referenceIndex\":1,\"score\":0.5722247362136841,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Delegated Setup. ...411Creation Method...415Implicit Setup...424Prebuilt Fixture...429Lazy Setup...435Suite Fixture Setup ...。。。441Setup Decorator...447Chained Tests...454Chapter 21. Result Verification Patterns p·...461State Verification...462Behavior Verification...468Custom Assertion...474Delta Assertion...485Guard Assertion...490Unfinished Test Assertion...494Chapter 22. Fixture Teardown Patterns...499Garbage-Collected Teardown...500CONTENTSAutomated Teardown...503In-line Teardown...509Implicit Teardown...516Chapter 23. Test Double Patterns ...521Test Double...522Test Stub...529\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_40\",\"images\":[],\"referenceIndex\":2,\"score\":0.5684536695480347,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":3,\"score\":0.5677477717399597,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":4,\"score\":0.5674441456794739,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":5,\"score\":0.5672414302825928,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]","action_name":"知识检索","action":"rag","arguments":"{}"},{"thought":"好的,用户让我总结一下第一本书的内容,也就是《xUnit Test Patterns》。首先,我需要回顾知识库中的相关文档。用户之前已经询问过xUnit相关的书籍,现在需要更深入的信息。\n\n首先,知识库中有多个条目提到了这本书,每个条目都引用了书中的不同章节和内容。例如,文档[1]提到了测试自动化策略、开发流程、客户测试、单元测试和测试组织。文档[2]和[3]提到了具体的模式,如Delegated Setup、Creation Method、Fixture管理、测试验证模式等。文档[4]和[5]讨论了数据库测试、测试自动化路线图以及结果验证的方法。\n\n用户的问题是要总结第一本书的内容,即《xUnit Test Patterns》。根据知识库中的信息,这本书主要围绕测试模式和最佳实践展开,涵盖测试结构、组织、验证、固件管理等方面。需要将这些分散的信息整合起来,形成一个结构化的总结。\n\n接下来,我需要确定这本书的核心主题。从各个文档的正文来看,书中讨论了测试代码的坏味道(Test Smells)、重构测试代码的方法、测试自动化策略、测试固件的管理(如Setup和Teardown模式)、测试验证模式(如状态验证和行为验证)、测试替身(Test Doubles)如Test Stub等。此外,还涉及测试组织结构、测试用例类设计、数据库测试的策略和挑战。\n\n用户可能希望了解这本书的整体框架和关键点,而不仅仅是零散的章节内容。因此,总结时需要分模块或主题来组织信息,例如核心概念、测试模式、实践策略、高级主题等。同时,要突出书中的核心贡献,如对测试模式的分类和解决方案。\n\n需要注意的是,知识库中的信息可能不完整,但可以基于现有内容进行合理推断。例如,文档[1]提到了测试坏味道的分类,文档[2]和[5]详细描述了不同的测试模式和验证方法,文档[3]和[4]讨论了测试组织和数据库测试的挑战。结合这些,可以推断该书系统性地介绍了如何编写可维护、高效的测试代码,解决测试中的常见问题。\n\n最后,需要确保总结简洁明了,涵盖主要章节和关键概念,让用户快速了解这本书的价值和内容结构。可能还需要指出这本书适合的读者群体,如测试工程师、开发人员以及需要提高测试代码质量的团队。","action_type":"reasoning","response":"好的,用户让我总结一下第一本书的内容,也就是《xUnit Test Patterns》。首先,我需要回顾知识库中的相关文档。用户之前已经询问过xUnit相关的书籍,现在需要更深入的信息。\n\n首先,知识库中有多个条目提到了这本书,每个条目都引用了书中的不同章节和内容。例如,文档[1]提到了测试自动化策略、开发流程、客户测试、单元测试和测试组织。文档[2]和[3]提到了具体的模式,如Delegated Setup、Creation Method、Fixture管理、测试验证模式等。文档[4]和[5]讨论了数据库测试、测试自动化路线图以及结果验证的方法。\n\n用户的问题是要总结第一本书的内容,即《xUnit Test Patterns》。根据知识库中的信息,这本书主要围绕测试模式和最佳实践展开,涵盖测试结构、组织、验证、固件管理等方面。需要将这些分散的信息整合起来,形成一个结构化的总结。\n\n接下来,我需要确定这本书的核心主题。从各个文档的正文来看,书中讨论了测试代码的坏味道(Test Smells)、重构测试代码的方法、测试自动化策略、测试固件的管理(如Setup和Teardown模式)、测试验证模式(如状态验证和行为验证)、测试替身(Test Doubles)如Test Stub等。此外,还涉及测试组织结构、测试用例类设计、数据库测试的策略和挑战。\n\n用户可能希望了解这本书的整体框架和关键点,而不仅仅是零散的章节内容。因此,总结时需要分模块或主题来组织信息,例如核心概念、测试模式、实践策略、高级主题等。同时,要突出书中的核心贡献,如对测试模式的分类和解决方案。\n\n需要注意的是,知识库中的信息可能不完整,但可以基于现有内容进行合理推断。例如,文档[1]提到了测试坏味道的分类,文档[2]和[5]详细描述了不同的测试模式和验证方法,文档[3]和[4]讨论了测试组织和数据库测试的挑战。结合这些,可以推断该书系统性地介绍了如何编写可维护、高效的测试代码,解决测试中的常见问题。\n\n最后,需要确保总结简洁明了,涵盖主要章节和关键概念,让用户快速了解这本书的价值和内容结构。可能还需要指出这本书适合的读者群体,如测试工程师、开发人员以及需要提高测试代码质量的团队。","action_name":"思考过程","action":"reasoning"}],"finish_reason":"stop","session_id":"9995da2046a04b448dc5a562563f4835","text":"根据知识库中提供的《xUnit Test Patterns》内容片段,以下是其核心内容的总结:\n\n---\n\n### **《xUnit Test Patterns: Refactoring Test Code》核心内容**\n1. **核心目标** \n 系统化解决单元测试中的常见问题,提供可复用的测试模式,帮助编写**可维护、高效、可靠**的测试代码。\n\n2. **关键主题** \n - **测试代码重构** \n - 识别测试代码的\"坏味道\"(Test Smells),例如冗长的测试方法、重复的测试逻辑、脆弱的依赖等。\n - 提出重构策略,如使用 **Creation Method** 简化对象构造、**Implicit Setup** 隐式初始化测试夹具等。\n - **测试自动化策略** \n - 强调\"测试即代码\"(Test as Code),通过设计模式(如 **Test Double**、**Test Stub**)隔离外部依赖。\n - 探讨测试与数据库交互的挑战(如事务管理、数据污染),并给出解决方案(如 **Fresh Fixture** 模式)。\n - **测试验证模式** \n - **State Verification**:验证被测对象的状态变化(如属性值)。\n - **Behavior Verification**:验证对象间的交互行为(如方法调用次数)。\n - **Custom Assertion**:通过自定义断言提高测试可读性。\n - **测试组织结构** \n - 按类、功能或夹具组织测试用例(如 **Testcase Class per Fixture**)。\n - 管理测试套件(Test Suites)和测试依赖关系。\n\n3. **典型模式示例** \n - **Fixture 管理** \n - **Delegated Setup**:将夹具构造逻辑委托给辅助方法。\n - **Prebuilt Fixture**:预构建共享夹具以提升性能。\n - **结果验证** \n - **Delta Assertion**:仅验证关键变化值,避免全量断言。\n - **Guard Assertion**:前置条件检查,防止测试误报。\n - **测试替身(Test Doubles)** \n - **Test Stub**:模拟外部依赖的返回值。\n - **Mock Object**:验证对象间的交互是否符合预期。\n\n4. **实践指导** \n - 提出从\"Happy Path\"(正常流程)到复杂场景的测试演进路线。\n - 强调测试的**独立性**(避免测试间依赖)和**自检能力**(无需人工验证结果)。\n\n---\n\n### **适用场景**\n- 开发人员需解决测试代码**臃肿、脆弱或低效**的问题。\n- 团队需建立**统一、可扩展**的自动化测试规范。\n- 涉及**数据库、外部服务**等复杂依赖的测试设计。\n\n书中内容以模式目录形式呈现,可直接作为工具手册使用。"},"usage":{"models":[{"output_tokens":1081,"model_id":"deepseek-r1","input_tokens":1283}]},"request_id":"703ba252-43c0-9a05-a656-1c2bf03d21dc"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt new file mode 100644 index 0000000..974d269 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-conversation-generation-session-id-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: 703ba252-43c0-9a05-a656-1c2bf03d21dc +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 50805 +req-arrive-time: 1742117445974 +resp-start-time: 1742117496779 +x-envoy-upstream-service-time: 50796 +content-encoding: gzip +date: Sun, 16 Mar 2025 09:31:36 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.body.json new file mode 100644 index 0000000..fc5092e --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.body.json @@ -0,0 +1,15 @@ +{ + "input": { + "prompt": "总结xUnit Test Patterns中的内容" + }, + "parameters": { + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85, + "rag_options": { + "pipeline_ids": ["thie5bysoj"], + "file_ids": ["file_d129d632800c45aa9e7421b30561f447_10207234"] + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.header.txt new file mode 100644 index 0000000..ef611ed --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.request.header.txt @@ -0,0 +1,9 @@ +POST /api/v1/apps/5ccc140108fd4b2ea5e6101fbada7583/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Postman-Token: 64f6ef44-2032-4b11-a8cb-f88353690719 +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 446 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.body.txt new file mode 100644 index 0000000..1d4bb11 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"thoughts":[{"action_input_stream":"{}","action_type":"agentRag","observation":"[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]","action_name":"知识检索","action":"rag","arguments":"{}"},{"action_input_stream":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"总结xUnit Test Patterns中的内容\"}","action_type":"api","observation":"[]","action_name":"长期记忆检索","action":"memory","arguments":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"总结xUnit Test Patterns中的内容\"}"}],"finish_reason":"stop","session_id":"b7250cba47db463ca851dfb4088e71d8","text":"xUnit Test Patterns 提供了一套全面的指南,用于改进测试自动化和重构测试代码。以下是根据提供的文档内容总结的关键点:\n\n1. 测试自动化的目标包括帮助提高产品质量、帮助我们理解被测系统(SUT)、减少(并且不引入)风险、易于运行、编写和维护[4]。\n2. 在管理共享fixture方面,文档讨论了访问共享fixture以及触发共享fixture构造的方法[2]。\n3. 关于结果验证,文档提供了自我检查测试的方法,验证状态或行为,使用内置断言进行状态验证,以及验证直接输出和替代路径[2]。\n4. 当涉及到数据库时,文档提到了与数据库相关的测试问题、没有数据库的测试、数据库测试、存储过程测试、数据访问层测试,并强调确保开发者独立性[3]。\n5. 文档还涵盖了测试方法组织策略、测试命名约定、测试套件组织、运行测试组或单个测试、测试代码重用、测试文件组织等内容[5]。\n\n这些模式和实践旨在解决测试中的常见问题,如高测试维护成本、不可测试代码最小化、防止生产代码中的错误测试等[1]。通过应用这些模式,开发者可以创建更高效、更易于维护的自动化测试。","doc_references":[{"images":["http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648","http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302"],"doc_name":"xUnit Test Patterns","text":"【文档名】:xUnit Test Patterns\n【标题】:Visual Summary of the Pattern Language\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\n","index_id":"1","title":"Visual Summary of the Pattern Language","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"doc_name":"xUnit Test Patterns","text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"doc_name":"xUnit Test Patterns","text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"doc_name":"xUnit Test Patterns","text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"doc_name":"xUnit Test Patterns","text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n","index_id":"5","title":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"output_tokens":290,"model_id":"qwen-plus","input_tokens":2591}]},"request_id":"c127bd40-180c-9cfa-b991-f875edd8c310"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.header.txt new file mode 100644 index 0000000..66978ab --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: c127bd40-180c-9cfa-b991-f875edd8c310 +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 14424 +req-arrive-time: 1742051106547 +resp-start-time: 1742051120971 +x-envoy-upstream-service-time: 14414 +content-encoding: gzip +date: Sat, 15 Mar 2025 15:05:20 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.body.json new file mode 100644 index 0000000..b3d4bec --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.body.json @@ -0,0 +1,16 @@ +{ + "input": { + "prompt": "总结xUnit Test Patterns中的内容" + }, + "parameters": { + "incremental_output": true, + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85, + "rag_options": { + "pipeline_ids": ["thie5bysoj"], + "tags": ["xUnit"] + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.header.txt new file mode 100644 index 0000000..85f63a1 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/010aa085cc9943268731861c9511bb0c/completion HTTP/1.1 +Accept: text/event-stream +Content-Type: application/json +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 364 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.body.txt new file mode 100644 index 0000000..012292e --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.body.txt @@ -0,0 +1,325 @@ +id:1 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"x"},"usage":{"models":[{"input_tokens":2304,"output_tokens":1,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:2 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"Unit"},"usage":{"models":[{"input_tokens":2304,"output_tokens":2,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:3 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":" Test"},"usage":{"models":[{"input_tokens":2304,"output_tokens":3,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:4 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":" Patterns这本书讨论了"},"usage":{"models":[{"input_tokens":2304,"output_tokens":7,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:5 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"测试自动化的目标,"},"usage":{"models":[{"input_tokens":2304,"output_tokens":11,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:6 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"指出测试应该帮助"},"usage":{"models":[{"input_tokens":2304,"output_tokens":15,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:7 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"我们提高质量"},"usage":{"models":[{"input_tokens":2304,"output_tokens":18,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:8 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"[4],理解","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":27,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:10 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"被测系统(S","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":31,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:11 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"UT),减少(","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":35,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:12 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"而不是引入)风险","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":39,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:13 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":",并且应该易于","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":43,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:14 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"运行、编写和","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":47,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:15 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"维护。书中还","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":51,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:16 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"提到了一些关于","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":55,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:17 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"测试哲学的内容,","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":59,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:18 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"强调了为什么哲学","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":63,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:19 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"对于测试来说是","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":67,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:20 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"重要的。\n\n此外,","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":71,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:21 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"该书涵盖了如何","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":75,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:22 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"管理共享的测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":79,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:23 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"装置以及访问这些","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":83,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:24 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"装置的方法[2],并说明","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":95,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:27 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"了触发共享装置","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":99,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:28 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"构建的过程。在","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":103,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:29 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"结果验证方面,","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":107,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:30 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"书中区分了状态","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":111,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:31 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"验证与行为验证","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":115,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:32 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":",并介绍了使用内置","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":119,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:33 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"断言、增量","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":123,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:34 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"断言等技术","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":127,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:35 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"来减少测试代码","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":131,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:36 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"重复性的策略。\n\n","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":135,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:37 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"书中也探讨了","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":139,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:38 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"数据库相关的测试议题","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":143,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:39 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":",包括没有数据库","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":147,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:40 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"的情况下进行测试的方法","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":151,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:41 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":",测试存储过程","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":155,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:42 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":",数据访问层","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":159,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:43 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"的测试,以及","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":163,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:44 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"确保开发者独立性","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":167,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:45 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"的同时进行数据库测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":171,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:46 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"的重要性[","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":175,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:47 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"3]","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":179,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:48 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"。\n\n最后,在组织","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":183,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:49 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"测试用例类","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":187,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:50 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"方面,书中提出了","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":191,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:51 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"按类、特性","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":195,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:52 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"或装置创建测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":199,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:53 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"用例类的不同","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":203,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:54 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"策略,并讨论了","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":207,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:55 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"选择测试方法组织","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":211,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:56 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"策略、命名约定","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":215,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:57 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"、组织测试套","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":219,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:58 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"件、运行测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":223,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:59 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"组或单一测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":227,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:60 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"的方式,以及测试","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":231,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:61 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"代码重用的位置","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":235,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:62 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"等问题[","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":239,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:63 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"5]","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n","index_id":"5","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":243,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:64 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"null","text":"。","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n","index_id":"5","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":244,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + +id:65 +event:result +:HTTP_STATUS/200 +data:{"output":{"session_id":"069db8223d514dab91185954dc5108de","finish_reason":"stop","text":"","doc_references":[{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n","index_id":"2","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n","index_id":"3","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n","index_id":"4","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"},{"images":[],"text":"【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n","index_id":"5","title":"xUnit Test Patterns","doc_name":"xUnit Test Patterns","doc_id":"file_d129d632800c45aa9e7421b30561f447_10207234"}]},"usage":{"models":[{"input_tokens":2304,"output_tokens":244,"model_id":"qwen-max-latest"}]},"request_id":"44862941-b743-9332-b49f-5f3db75a4873"} + diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.header.txt new file mode 100644 index 0000000..4741d69 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-sse.response.header.txt @@ -0,0 +1,14 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers +x-request-id: fec856c6-c146-99bc-940c-fd6c36939a16 +content-type: text/event-stream;charset=UTF-8 +x-dashscope-call-gateway: true +x-dashscope-timeout: 180 +x-dashscope-finished: false +req-cost-time: 1755 +req-arrive-time: 1742113457368 +resp-start-time: 1742113459124 +x-envoy-upstream-service-time: 1744 +date: Sun, 16 Mar 2025 08:24:18 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json new file mode 100644 index 0000000..b4321ca --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.body.json @@ -0,0 +1,13 @@ +{ + "input": { + "prompt": "我爱吃面食", + "memory_id": "ffd8be2352d84c6b9350e91c865b512e" + }, + "parameters": { + "has_thoughts": true, + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85 + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt new file mode 100644 index 0000000..7548692 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/5ccc140108fd4b2ea5e6101fbada7583/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 280 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt new file mode 100644 index 0000000..e8d1965 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"thoughts":[{"action_input_stream":"{}","action_type":"agentRag","observation":"[]","action_name":"知识检索","action":"rag","arguments":"{}"},{"action_input_stream":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"我爱吃面食\"}","action_type":"api","observation":"[\"[2025-3-16 20:47:40 周日] 用户喜欢吃面食。\"]","action_name":"长期记忆检索","action":"memory","arguments":"{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"我爱吃面食\"}"}],"finish_reason":"stop","session_id":"cd395cb8d4604db786a14555fdcffa1a","text":"那您一定会对面条、馒头或者饺子这些美食很感兴趣呢!如果您有特定的面食问题或者需要推荐相关的菜品,可以告诉我,我很乐意为您提供帮助[1]。"},"usage":{"models":[{"output_tokens":43,"model_id":"qwen-plus","input_tokens":1201}]},"request_id":"8cea84fe-2770-91b0-a6d1-e1e8ef176fa6"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt new file mode 100644 index 0000000..c6a1483 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-memory-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: 8cea84fe-2770-91b0-a6d1-e1e8ef176fa6 +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 2516 +req-arrive-time: 1742129333100 +resp-start-time: 1742129335617 +x-envoy-upstream-service-time: 2508 +content-encoding: gzip +date: Sun, 16 Mar 2025 12:48:55 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json new file mode 100644 index 0000000..dad1501 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.body.json @@ -0,0 +1,16 @@ +{ + "input": { + "prompt": "总结xUnit Test Patterns中的内容" + }, + "parameters": { + "has_thoughts": true, + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85, + "rag_options": { + "pipeline_ids": ["thie5bysoj"], + "file_ids": ["file_d129d632800c45aa9e7421b30561f447_10207234"] + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt new file mode 100644 index 0000000..01c9f0f --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/010aa085cc9943268731861c9511bb0c/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 403 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt new file mode 100644 index 0000000..1dab922 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"thoughts":[{"action_input_stream":"{}","action_type":"agentRag","observation":"[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=4CddPVeeyxgrXe5axUspV6zXnS8%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=hRkFcnwAiV7LSHw69WvJJ6fXEV0%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]","action_name":"知识检索","action":"rag","arguments":"{}"},{"thought":"好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。","action_type":"reasoning","response":"好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。","action_name":"思考过程","action":"reasoning"}],"finish_reason":"stop","session_id":"9d81b84e95f844c29ee825ad8bb647bb","text":"《xUnit Test Patterns》是一本系统介绍单元测试模式与最佳实践的指南,主要帮助开发者设计可维护、高效且可靠的自动化测试。以下是其核心内容的总结:\n\n---\n\n### **核心主题与内容**\n1. **测试模式与反模式**\n - **关键模式**:如共享夹具管理(Shared Fixtures)、自定义断言(Custom Assertions)、预期对象(Expected Objects)等,用于解决测试代码重复、依赖管理等问题。\n - **反模式与问题**:如不可测试代码(Untestable Code)、测试逻辑混入生产代码(Test Logic in Production)、高维护成本(High Test Maintenance Cost)等,分析其成因与规避策略。\n\n2. **测试夹具管理**\n - **共享夹具**:如何构造、触发和访问共享测试环境(如数据库连接),避免测试间的副作用。\n - **数据库测试**:讨论是否依赖数据库进行测试、如何测试数据访问层、存储过程,以及确保开发者独立性的策略(如使用测试替身)。\n\n3. **测试验证策略**\n - **状态验证**:通过断言检查系统状态(如使用内置断言、Delta断言)。\n - **行为验证**:验证系统是否按预期调用方法(如模拟对象、过程式验证)。\n - **减少代码重复**:通过自定义断言、预期对象和验证方法统一结果检查逻辑。\n\n4. **测试自动化哲学与目标**\n - **目标**:提升代码质量、降低风险、易于编写和维护测试。\n - **经济性**:平衡测试投入与收益,优先覆盖关键路径(Happy Path)和替代路径(Alternative Paths)。\n\n5. **测试代码组织**\n - **结构化策略**:按类(Testcase Class per Class)、功能(Testcase Class per Feature)或夹具(Testcase Class per Fixture)组织测试用例。\n - **命名与套件管理**:使用清晰命名约定、分组测试套件(Test Suites)和依赖管理。\n\n6. **测试维护与演进**\n - **最小化维护成本**:通过模式(如测试工具方法、继承复用)适应系统变化。\n - **自检测试(Built-in Self-Test)**:确保测试本身的可信性。\n\n---\n\n### **书籍结构特点**\n- **问题驱动**:每章围绕具体问题(如“如何处理共享夹具?”)展开,提供模式、替代方案和权衡。\n- **视觉化总结**:通过图表展示模式间的关系,帮助读者理解复杂概念。\n- **实践导向**:结合代码示例与真实场景,指导如何应用模式解决测试中的常见痛点。\n\n---\n\n### **适用场景**\n- 开发中遇到测试代码重复、脆弱测试(Fragile Tests)或高维护成本时。\n- 需要设计复杂测试场景(如数据库交互、异步行为)时。\n- 团队希望建立统一的测试实践与规范时。\n\n通过遵循书中模式,开发者能构建更健壮、可维护的测试体系,最终提升软件质量和开发效率。"},"usage":{"models":[{"output_tokens":1126,"model_id":"deepseek-r1","input_tokens":1129}]},"request_id":"b5819020-e5aa-9481-8c9d-e11797f191d8"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt new file mode 100644 index 0000000..24f9fde --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-single-generation-text-with-thought-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: b5819020-e5aa-9481-8c9d-e11797f191d8 +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 43838 +req-arrive-time: 1742111961733 +resp-start-time: 1742112005571 +x-envoy-upstream-service-time: 43826 +content-encoding: gzip +date: Sun, 16 Mar 2025 08:00:05 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.body.json b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.body.json new file mode 100644 index 0000000..6b55694 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.body.json @@ -0,0 +1,14 @@ +{ + "input": { + "prompt": "请你跟我这样说", + "biz_params": { + "sourceCode": "code" + } + }, + "parameters": { + "top_k": 100, + "top_p": 0.8, + "seed": 1234, + "temperature": 0.85 + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.header.txt new file mode 100644 index 0000000..e0c52bd --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.request.header.txt @@ -0,0 +1,8 @@ +POST /api/v1/apps/debbb624ccfd4ebdac605edc27f94f7a/completion HTTP/1.1 +Content-Type: application/json +Accept: */* +Cache-Control: no-cache +Host: dashscope.aliyuncs.com +Accept-Encoding: gzip, deflate, br +Connection: keep-alive +Content-Length: 268 diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.body.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.body.txt new file mode 100644 index 0000000..c882c92 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.body.txt @@ -0,0 +1 @@ +{"output":{"finish_reason":"stop","session_id":"5a20b47dac2f43a7b1cbb8924ca66c47","text":"code"},"usage":{},"request_id":"10990f51-e2d0-9338-9c52-319af5f4858b"} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.header.txt b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.header.txt new file mode 100644 index 0000000..087d6ad --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/RawHttpData/application-workflow-nosse.response.header.txt @@ -0,0 +1,15 @@ +HTTP/1.1 200 OK +vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding +content-type: application/json +x-request-id: 10990f51-e2d0-9338-9c52-319af5f4858b +x-dashscope-timeout: 180 +x-dashscope-call-gateway: true +x-dashscope-finished: true +req-cost-time: 414 +req-arrive-time: 1742133858888 +resp-start-time: 1742133859303 +x-envoy-upstream-service-time: 406 +content-encoding: gzip +date: Sun, 16 Mar 2025 14:04:18 GMT +server: istio-envoy +transfer-encoding: chunked diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs new file mode 100644 index 0000000..6ad5bb1 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Application.cs @@ -0,0 +1,391 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class Application + { + public static readonly RequestSnapshot SinglePromptNoSse = + new( + "application-single-generation-text", + new ApplicationRequest() + { + Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["thie5bysoj"], + FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + } + } + }, + new ApplicationResponse( + "c127bd40-180c-9cfa-b991-f875edd8c310", + new ApplicationOutput( + "xUnit Test Patterns 提供了一套全面的指南,用于改进测试自动化和重构测试代码。以下是根据提供的文档内容总结的关键点:\n\n1. 测试自动化的目标包括帮助提高产品质量、帮助我们理解被测系统(SUT)、减少(并且不引入)风险、易于运行、编写和维护[4]。\n2. 在管理共享fixture方面,文档讨论了访问共享fixture以及触发共享fixture构造的方法[2]。\n3. 关于结果验证,文档提供了自我检查测试的方法,验证状态或行为,使用内置断言进行状态验证,以及验证直接输出和替代路径[2]。\n4. 当涉及到数据库时,文档提到了与数据库相关的测试问题、没有数据库的测试、数据库测试、存储过程测试、数据访问层测试,并强调确保开发者独立性[3]。\n5. 文档还涵盖了测试方法组织策略、测试命名约定、测试套件组织、运行测试组或单个测试、测试代码重用、测试文件组织等内容[5]。\n\n这些模式和实践旨在解决测试中的常见问题,如高测试维护成本、不可测试代码最小化、防止生产代码中的错误测试等[1]。通过应用这些模式,开发者可以创建更高效、更易于维护的自动化测试。", + "stop", + "b7250cba47db463ca851dfb4088e71d8", + [ + new ApplicationOutputThought( + null, + "agentRag", + "知识检索", + "rag", + "{}", + null, + "[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]", + null, + "{}"), + new ApplicationOutputThought( + null, + "api", + "长期记忆检索", + "memory", + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"总结xUnit Test Patterns中的内容\"}", + null, + "[]", + null, + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"总结xUnit Test Patterns中的内容\"}") + ], + [ + new ApplicationDocReference( + "1", + "Visual Summary of the Pattern Language", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:Visual Summary of the Pattern Language\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\n", + [ + "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=89B%2FoauA6i4g34LikZ06Z0PUHY4%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648", + "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742655907&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=3VwzeegSrkzfQIcMDz2F3C2bTdg%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302" + ], + null), + new ApplicationDocReference( + "2", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n", + [], + null), + new ApplicationDocReference( + "3", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n", + [], + null), + new ApplicationDocReference( + "4", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n", + [], + null), + new ApplicationDocReference( + "5", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n", + [], + null) + ]), + new ApplicationUsage([new ApplicationModelUsage("qwen-plus", 2591, 290)]))); + + public static readonly RequestSnapshot SinglePromptSse = + new( + "application-single-generation-text", + new ApplicationRequest() + { + Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + IncrementalOutput = true, + RagOptions = new ApplicationRagOptions() { PipelineIds = ["thie5bysoj"], Tags = ["xUnit"] } + } + }, + new ApplicationResponse( + "44862941-b743-9332-b49f-5f3db75a4873", + new ApplicationOutput( + "xUnit Test Patterns这本书讨论了测试自动化的目标,指出测试应该帮助我们提高质量[4],理解被测系统(SUT),减少(而不是引入)风险,并且应该易于运行、编写和维护。书中还提到了一些关于测试哲学的内容,强调了为什么哲学对于测试来说是重要的。\n\n此外,该书涵盖了如何管理共享的测试装置以及访问这些装置的方法[2],并说明了触发共享装置构建的过程。在结果验证方面,书中区分了状态验证与行为验证,并介绍了使用内置断言、增量断言等技术来减少测试代码重复性的策略。\n\n书中也探讨了数据库相关的测试议题,包括没有数据库的情况下进行测试的方法,测试存储过程,数据访问层的测试,以及确保开发者独立性的同时进行数据库测试的重要性[3]。\n\n最后,在组织测试用例类方面,书中提出了按类、特性或装置创建测试用例类的不同策略,并讨论了选择测试方法组织策略、命名约定、组织测试套件、运行测试组或单一测试的方式,以及测试代码重用的位置等问题[5]。", + "stop", + "069db8223d514dab91185954dc5108de", + null, + [ + new ApplicationDocReference( + "2", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\n", + [], + null), + new ApplicationDocReference( + "3", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\n", + [], + null), + new ApplicationDocReference( + "4", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\n", + [], + null), + new ApplicationDocReference( + "5", + "xUnit Test Patterns", + "file_d129d632800c45aa9e7421b30561f447_10207234", + "xUnit Test Patterns", + "【文档名】:xUnit Test Patterns\n【标题】:xUnit Test Patterns\n文档类型:[\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\",\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\"]\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\n", + [], + null), + ]), + new ApplicationUsage([new ApplicationModelUsage("qwen-max-latest", 2304, 244)]))); + + public static readonly RequestSnapshot SinglePromptWithThoughtsNoSse = + new( + "application-single-generation-text-with-thought", + new ApplicationRequest() + { + Input = new ApplicationInput() { Prompt = "总结xUnit Test Patterns中的内容" }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["thie5bysoj"], + FileIds = ["file_d129d632800c45aa9e7421b30561f447_10207234"] + }, + HasThoughts = true + } + }, + new ApplicationResponse( + "b5819020-e5aa-9481-8c9d-e11797f191d8", + new ApplicationOutput( + "《xUnit Test Patterns》是一本系统介绍单元测试模式与最佳实践的指南,主要帮助开发者设计可维护、高效且可靠的自动化测试。以下是其核心内容的总结:\n\n---\n\n### **核心主题与内容**\n1. **测试模式与反模式**\n - **关键模式**:如共享夹具管理(Shared Fixtures)、自定义断言(Custom Assertions)、预期对象(Expected Objects)等,用于解决测试代码重复、依赖管理等问题。\n - **反模式与问题**:如不可测试代码(Untestable Code)、测试逻辑混入生产代码(Test Logic in Production)、高维护成本(High Test Maintenance Cost)等,分析其成因与规避策略。\n\n2. **测试夹具管理**\n - **共享夹具**:如何构造、触发和访问共享测试环境(如数据库连接),避免测试间的副作用。\n - **数据库测试**:讨论是否依赖数据库进行测试、如何测试数据访问层、存储过程,以及确保开发者独立性的策略(如使用测试替身)。\n\n3. **测试验证策略**\n - **状态验证**:通过断言检查系统状态(如使用内置断言、Delta断言)。\n - **行为验证**:验证系统是否按预期调用方法(如模拟对象、过程式验证)。\n - **减少代码重复**:通过自定义断言、预期对象和验证方法统一结果检查逻辑。\n\n4. **测试自动化哲学与目标**\n - **目标**:提升代码质量、降低风险、易于编写和维护测试。\n - **经济性**:平衡测试投入与收益,优先覆盖关键路径(Happy Path)和替代路径(Alternative Paths)。\n\n5. **测试代码组织**\n - **结构化策略**:按类(Testcase Class per Class)、功能(Testcase Class per Feature)或夹具(Testcase Class per Fixture)组织测试用例。\n - **命名与套件管理**:使用清晰命名约定、分组测试套件(Test Suites)和依赖管理。\n\n6. **测试维护与演进**\n - **最小化维护成本**:通过模式(如测试工具方法、继承复用)适应系统变化。\n - **自检测试(Built-in Self-Test)**:确保测试本身的可信性。\n\n---\n\n### **书籍结构特点**\n- **问题驱动**:每章围绕具体问题(如“如何处理共享夹具?”)展开,提供模式、替代方案和权衡。\n- **视觉化总结**:通过图表展示模式间的关系,帮助读者理解复杂概念。\n- **实践导向**:结合代码示例与真实场景,指导如何应用模式解决测试中的常见痛点。\n\n---\n\n### **适用场景**\n- 开发中遇到测试代码重复、脆弱测试(Fragile Tests)或高维护成本时。\n- 需要设计复杂测试场景(如数据库交互、异步行为)时。\n- 团队希望建立统一的测试实践与规范时。\n\n通过遵循书中模式,开发者能构建更健壮、可维护的测试体系,最终提升软件质量和开发效率。", + "stop", + "9d81b84e95f844c29ee825ad8bb647bb", + [ + new ApplicationOutputThought( + null, + "agentRag", + "知识检索", + "rag", + "{}", + null, + "[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:Visual Summary of the Pattern Language\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Minimize Untestable Code Buggy Tests Production Bugs Keep Test Logic Out of Production Developers Not Writing Tests Ensure Commensurate Effort and Responsibility High Test Maintenance CostKey to Visual Summary of the Pattern Language Chapter Name Chapter Name Sub-Category, Altemative Pattern Smell Pattern 1Pattern 2from Other Chapter'Cause of Smell Sub-Category variation, of Altemative Pattem十Pattem 1Smell Variation of Pattern used with Pattern leads toi Smell Variation described each other Alternative Pattem 2separatelyVISUAL SUMMARY OF THE PATTERN LANGUAGE\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_1_3\",\"images\":[\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=4CddPVeeyxgrXe5axUspV6zXnS8%3D&x-oss-process=image%2Fcrop%2Cx_232%2Cy_610%2Cw_964%2Ch_648\",\"http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1257896666798445/publicDocStructure/docmind-20250315-ee118d3555104aba9200f6cf525bae0a/19.png?Expires=1742716762&OSSAccessKeyId=LTAI5tFEK2uEApeeYzxNMEci&Signature=hRkFcnwAiV7LSHw69WvJJ6fXEV0%3D&x-oss-process=image%2Fcrop%2Cx_227%2Cy_1305%2Cw_991%2Ch_302\"],\"referenceIndex\":1,\"score\":0.5756075978279114,\"title\":\"Visual Summary of the Pattern Language\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":2,\"score\":0.5756075978279114,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":3,\"score\":0.5697553753852844,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19About This Chapter...19Why Test?...19Economics of Test Automation20Goals of Test Automation...21Tests Should Help Us Improve Quality...22Tests Should Help Us Understand the SUT. . ...23Tests Should Reduce (and Not Introduce) Risk...23Tests Should Be Easy to Run ...25Tests Should Be Easy to Write and Maintain ...27Tests Should Require Minimal Maintenance asthe System Evolves Around Them ...29What's Next? .29Chapter 4. Philosophy of Test Automation ...31About This Chapter...31Why Is Philosophy Important?...31\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_28\",\"images\":[],\"referenceIndex\":4,\"score\":0.5639580488204956,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"xUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\",\\\"XUNIT TEST Yoog PATTERNS REFACTORING TEST CODE GERARD)1MESZAROS\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_thie5bysoj_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":5,\"score\":0.563438355922699,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]", + null, + "{}"), + new ApplicationOutputThought( + "好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。", + "reasoning", + "思考过程", + "reasoning", + null, + null, + null, + "好的,我现在需要总结用户提供的xUnit Test Patterns中的内容。首先,用户给了几个文档片段,每个片段都来自同一本书的不同部分。我需要仔细分析这些片段,看看里面提到的关键点和主题。\n\n第一个文档提到了“Visual Summary of the Pattern Language”,里面有几个关键点,比如Minimize Untestable Code,Buggy Tests,Production Bugs,还有测试维护成本高的问题。可能这本书在讲如何设计和管理单元测试的模式,避免常见的问题,比如不可测试的代码和测试逻辑混入生产环境。\n\n第二个文档片段讲的是“Managing Shared Fixtures”和结果验证(Result Verification)。这里提到共享夹具的管理、触发构建,以及如何验证测试结果,包括状态验证和行为验证,还有减少测试代码重复的方法,比如使用Expected Objects和Custom Assertions。这说明书中详细讨论了测试夹具的设计和如何有效验证测试结果,避免重复代码。\n\n第三个文档涉及数据库测试的问题,比如如何测试数据访问层、存储过程,以及确保开发者独立性的策略。这部分可能讨论在测试中使用数据库的挑战和解决方案,例如是否使用数据库进行测试,或者如何隔离测试以避免依赖。\n\n第四个文档提到了测试自动化的目标和哲学,包括测试的经济性、提高质量、理解系统、降低风险、易于运行和维护等。这说明书中不仅提供技术模式,还强调测试策略和哲学的重要性,指导如何有效实施自动化测试。\n\n第五个文档讨论了测试用例的组织策略,比如按类、功能或夹具组织测试用例类,命名约定,测试套件的管理,以及测试代码的重用方法。这部分可能涉及如何结构化测试代码,提高可维护性和可读性。\n\n综合这些片段,xUnit Test Patterns似乎是一本关于单元测试设计和最佳实践的指南,涵盖测试模式、夹具管理、结果验证、数据库测试、测试自动化策略和测试代码组织。重点在于如何编写可维护、可靠且高效的测试,避免常见陷阱,如不可测试的代码、测试逻辑污染生产代码、高维护成本等。书中可能还讨论了如何在不同情境下选择适当的测试策略,例如是否使用共享夹具,如何处理数据库依赖,以及如何组织测试代码结构以提高复用性。\n\n现在需要将这些分析整理成一个简明扼要的总结,突出主要主题和关键点,确保涵盖各个文档片段提到的内容,并指出这本书的整体目的和结构。可能需要分点说明,让用户清晰了解书中的核心内容。", + null) + ], + null), + new ApplicationUsage([new ApplicationModelUsage("deepseek-r1", 1129, 1126)]))); + + public static readonly RequestSnapshot SinglePromptWithMemoryNoSse = + new( + "application-single-generation-text-with-memory", + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Prompt = "我爱吃面食", MemoryId = "ffd8be2352d84c6b9350e91c865b512e" + }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + HasThoughts = true + } + }, + new ApplicationResponse( + "8cea84fe-2770-91b0-a6d1-e1e8ef176fa6", + new ApplicationOutput( + "那您一定会对面条、馒头或者饺子这些美食很感兴趣呢!如果您有特定的面食问题或者需要推荐相关的菜品,可以告诉我,我很乐意为您提供帮助[1]。", + "stop", + "cd395cb8d4604db786a14555fdcffa1a", + [ + new ApplicationOutputThought(null, "agentRag", "知识检索", "rag", "{}", null, "[]", null, "{}"), + new ApplicationOutputThought( + null, + "api", + "长期记忆检索", + "memory", + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"我爱吃面食\"}", + null, + "[\"[2025-3-16 20:47:40 周日] 用户喜欢吃面食。\"]", + null, + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"我爱吃面食\"}") + ], + null), + new ApplicationUsage([new ApplicationModelUsage("qwen-plus", 1201, 43)]))); + + public static readonly RequestSnapshot, ApplicationResponse> + WorkflowNoSse = + new( + "application-workflow", + new ApplicationRequest() + { + Input = new ApplicationInput() + { + BizParams = new TestApplicationBizParam("code"), Prompt = "请你跟我这样说" + }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + } + }, + new ApplicationResponse( + "10990f51-e2d0-9338-9c52-319af5f4858b", + new ApplicationOutput("code", "stop", "5a20b47dac2f43a7b1cbb8924ca66c47", null, null), + new ApplicationUsage(null))); + + public static readonly RequestSnapshot ConversationSessionIdNoSse = + new( + "application-conversation-generation-session-id", + new ApplicationRequest() + { + Input = + new ApplicationInput() + { + Prompt = "总结一下第一本书的内容", SessionId = "9995da2046a04b448dc5a562563f4835" + }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["ll6yfcnxjg"], + MetadataFilter = new Dictionary { { "docType", "电子书" } } + }, + HasThoughts = true + } + }, + new ApplicationResponse( + "703ba252-43c0-9a05-a656-1c2bf03d21dc", + new ApplicationOutput( + "根据知识库中提供的《xUnit Test Patterns》内容片段,以下是其核心内容的总结:\n\n---\n\n### **《xUnit Test Patterns: Refactoring Test Code》核心内容**\n1. **核心目标** \n 系统化解决单元测试中的常见问题,提供可复用的测试模式,帮助编写**可维护、高效、可靠**的测试代码。\n\n2. **关键主题** \n - **测试代码重构** \n - 识别测试代码的\"坏味道\"(Test Smells),例如冗长的测试方法、重复的测试逻辑、脆弱的依赖等。\n - 提出重构策略,如使用 **Creation Method** 简化对象构造、**Implicit Setup** 隐式初始化测试夹具等。\n - **测试自动化策略** \n - 强调\"测试即代码\"(Test as Code),通过设计模式(如 **Test Double**、**Test Stub**)隔离外部依赖。\n - 探讨测试与数据库交互的挑战(如事务管理、数据污染),并给出解决方案(如 **Fresh Fixture** 模式)。\n - **测试验证模式** \n - **State Verification**:验证被测对象的状态变化(如属性值)。\n - **Behavior Verification**:验证对象间的交互行为(如方法调用次数)。\n - **Custom Assertion**:通过自定义断言提高测试可读性。\n - **测试组织结构** \n - 按类、功能或夹具组织测试用例(如 **Testcase Class per Fixture**)。\n - 管理测试套件(Test Suites)和测试依赖关系。\n\n3. **典型模式示例** \n - **Fixture 管理** \n - **Delegated Setup**:将夹具构造逻辑委托给辅助方法。\n - **Prebuilt Fixture**:预构建共享夹具以提升性能。\n - **结果验证** \n - **Delta Assertion**:仅验证关键变化值,避免全量断言。\n - **Guard Assertion**:前置条件检查,防止测试误报。\n - **测试替身(Test Doubles)** \n - **Test Stub**:模拟外部依赖的返回值。\n - **Mock Object**:验证对象间的交互是否符合预期。\n\n4. **实践指导** \n - 提出从\"Happy Path\"(正常流程)到复杂场景的测试演进路线。\n - 强调测试的**独立性**(避免测试间依赖)和**自检能力**(无需人工验证结果)。\n\n---\n\n### **适用场景**\n- 开发人员需解决测试代码**臃肿、脆弱或低效**的问题。\n- 团队需建立**统一、可扩展**的自动化测试规范。\n- 涉及**数据库、外部服务**等复杂依赖的测试设计。\n\n书中内容以模式目录形式呈现,可直接作为工具手册使用。", + "stop", + "9995da2046a04b448dc5a562563f4835", + [ + new ApplicationOutputThought( + null, + "agentRag", + "知识检索", + "rag", + "{}", + null, + "[{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Refactoring a Test...xlvPARTI.The Narratives····.1Chapter 1. A Brief Tour3About This Chapter3The Simplest Test Automation Strategy ThatCould Possibly Work3Development Process4Customer Tests5Unit Tests . . .Design for TestabilityTest Organization···What's Next?Chapter 2. Test Smells . . ..·····9About This Chapter9An Introduction to Test Smells..9What's a Test Smell? . . ...10Kinds of Test Smells ...10What to Do about Smells?..11A Catalog of Smells·...12The Project Smells...12The Behavior Smells. . ...13The Code Smells..16What's Next?..17viiiCONTENTSChapter 3. Goals of Test Automation ...19\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_27\",\"images\":[],\"referenceIndex\":1,\"score\":0.5722247362136841,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Delegated Setup. ...411Creation Method...415Implicit Setup...424Prebuilt Fixture...429Lazy Setup...435Suite Fixture Setup ...。。。441Setup Decorator...447Chained Tests...454Chapter 21. Result Verification Patterns p·...461State Verification...462Behavior Verification...468Custom Assertion...474Delta Assertion...485Guard Assertion...490Unfinished Test Assertion...494Chapter 22. Fixture Teardown Patterns...499Garbage-Collected Teardown...500CONTENTSAutomated Teardown...503In-line Teardown...509Implicit Teardown...516Chapter 23. Test Double Patterns ...521Test Double...522Test Stub...529\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_40\",\"images\":[],\"referenceIndex\":2,\"score\":0.5684536695480347,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Testcase Class per Class... ...155Testcase Class per Feature. ...156Testcase Class per Fixture...156Choosing a Test Method Organization Strategy...158Test Naming Conventions...158Organizing Test Suites.. . ...160Running Groups of Tests ...160Running a Single Test...161Test Code Reuse...162Test Utility Method Locations ...163TestCase Inheritance and Reuse...163Test File Organization...164Built-in Self-Test...164Test Packages. ...164Test Dependencies ...165What's Next? ...165Chapter 13. Testing with Databases...167About This Chapter...167Testing with Databases...167Why Test with Databases?...168\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_36\",\"images\":[],\"referenceIndex\":3,\"score\":0.5677477717399597,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:?...168Issues with Databases...168Testing without Databases...169Testing the Database...171Testing Stored Procedures...172Testing the Data Access Layer...172Ensuring Developer Independence...173Testing with Databases (Again!)...173What's Next? ...174Chapter 14. A Roadmap to Effective Test Automation ...175About This Chapter...175Test Automation Difficulty .. ...175Roadmap to Highly Maintainable Automated Tests...176Exercise the Happy Path Code ...177Verify Direct Outputs of the Happy Path...178CONTENTSVerify Alternative Paths...178Verify Indirect Output Behavior...179\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_37\",\"images\":[],\"referenceIndex\":4,\"score\":0.5674441456794739,\"title\":\"xUnit Test Patterns\",\"webSearch\":false},{\"content\":\"【文档名】:xUnit Test Patterns\\n【标题】:xUnit Test Patterns\\n文档类型:[\\\"电子书\\\"]\\n关键字:[\\\"xUnit\\\"]\\n【正文】:Managing Shared Fixtures...103Accessing Shared Fixtures...103Triggering Shared Fixture Construction...104What's Next?...106Chapter 10. Result Verification...107About This Chapter ...107Making Tests Self-Checking...107Verify State or Behavior?...108State Verification...109Using Built-in Assertions ...110Delta Assertions...111External Result Verification ...111Verifying Behavior...112Procedural Behavior Verification...113Expected Behavior Specification . . ...113CONTENTSReducing Test Code Duplication...114Expected Objects...115Custom Assertions...116Outcome-Describing Verification Method ...117\\n\",\"dataId\":\"file_d129d632800c45aa9e7421b30561f447_10207234\",\"dataName\":\"xUnit Test Patterns\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_ll6yfcnxjg_file_d129d632800c45aa9e7421b30561f447_10207234_0_33\",\"images\":[],\"referenceIndex\":5,\"score\":0.5672414302825928,\"title\":\"xUnit Test Patterns\",\"webSearch\":false}]", + null, + "{}"), + new ApplicationOutputThought( + "好的,用户让我总结一下第一本书的内容,也就是《xUnit Test Patterns》。首先,我需要回顾知识库中的相关文档。用户之前已经询问过xUnit相关的书籍,现在需要更深入的信息。\n\n首先,知识库中有多个条目提到了这本书,每个条目都引用了书中的不同章节和内容。例如,文档[1]提到了测试自动化策略、开发流程、客户测试、单元测试和测试组织。文档[2]和[3]提到了具体的模式,如Delegated Setup、Creation Method、Fixture管理、测试验证模式等。文档[4]和[5]讨论了数据库测试、测试自动化路线图以及结果验证的方法。\n\n用户的问题是要总结第一本书的内容,即《xUnit Test Patterns》。根据知识库中的信息,这本书主要围绕测试模式和最佳实践展开,涵盖测试结构、组织、验证、固件管理等方面。需要将这些分散的信息整合起来,形成一个结构化的总结。\n\n接下来,我需要确定这本书的核心主题。从各个文档的正文来看,书中讨论了测试代码的坏味道(Test Smells)、重构测试代码的方法、测试自动化策略、测试固件的管理(如Setup和Teardown模式)、测试验证模式(如状态验证和行为验证)、测试替身(Test Doubles)如Test Stub等。此外,还涉及测试组织结构、测试用例类设计、数据库测试的策略和挑战。\n\n用户可能希望了解这本书的整体框架和关键点,而不仅仅是零散的章节内容。因此,总结时需要分模块或主题来组织信息,例如核心概念、测试模式、实践策略、高级主题等。同时,要突出书中的核心贡献,如对测试模式的分类和解决方案。\n\n需要注意的是,知识库中的信息可能不完整,但可以基于现有内容进行合理推断。例如,文档[1]提到了测试坏味道的分类,文档[2]和[5]详细描述了不同的测试模式和验证方法,文档[3]和[4]讨论了测试组织和数据库测试的挑战。结合这些,可以推断该书系统性地介绍了如何编写可维护、高效的测试代码,解决测试中的常见问题。\n\n最后,需要确保总结简洁明了,涵盖主要章节和关键概念,让用户快速了解这本书的价值和内容结构。可能还需要指出这本书适合的读者群体,如测试工程师、开发人员以及需要提高测试代码质量的团队。", + "reasoning", + "思考过程", + "reasoning", + null, + null, + null, + "好的,用户让我总结一下第一本书的内容,也就是《xUnit Test Patterns》。首先,我需要回顾知识库中的相关文档。用户之前已经询问过xUnit相关的书籍,现在需要更深入的信息。\n\n首先,知识库中有多个条目提到了这本书,每个条目都引用了书中的不同章节和内容。例如,文档[1]提到了测试自动化策略、开发流程、客户测试、单元测试和测试组织。文档[2]和[3]提到了具体的模式,如Delegated Setup、Creation Method、Fixture管理、测试验证模式等。文档[4]和[5]讨论了数据库测试、测试自动化路线图以及结果验证的方法。\n\n用户的问题是要总结第一本书的内容,即《xUnit Test Patterns》。根据知识库中的信息,这本书主要围绕测试模式和最佳实践展开,涵盖测试结构、组织、验证、固件管理等方面。需要将这些分散的信息整合起来,形成一个结构化的总结。\n\n接下来,我需要确定这本书的核心主题。从各个文档的正文来看,书中讨论了测试代码的坏味道(Test Smells)、重构测试代码的方法、测试自动化策略、测试固件的管理(如Setup和Teardown模式)、测试验证模式(如状态验证和行为验证)、测试替身(Test Doubles)如Test Stub等。此外,还涉及测试组织结构、测试用例类设计、数据库测试的策略和挑战。\n\n用户可能希望了解这本书的整体框架和关键点,而不仅仅是零散的章节内容。因此,总结时需要分模块或主题来组织信息,例如核心概念、测试模式、实践策略、高级主题等。同时,要突出书中的核心贡献,如对测试模式的分类和解决方案。\n\n需要注意的是,知识库中的信息可能不完整,但可以基于现有内容进行合理推断。例如,文档[1]提到了测试坏味道的分类,文档[2]和[5]详细描述了不同的测试模式和验证方法,文档[3]和[4]讨论了测试组织和数据库测试的挑战。结合这些,可以推断该书系统性地介绍了如何编写可维护、高效的测试代码,解决测试中的常见问题。\n\n最后,需要确保总结简洁明了,涵盖主要章节和关键概念,让用户快速了解这本书的价值和内容结构。可能还需要指出这本书适合的读者群体,如测试工程师、开发人员以及需要提高测试代码质量的团队。", + null) + ], + null), + new ApplicationUsage([new ApplicationModelUsage("deepseek-r1", 1283, 1081)]))); + + public static readonly RequestSnapshot ConversationMessageNoSse = + new( + "application-conversation-generation-message", + new ApplicationRequest() + { + Input = new ApplicationInput() + { + Messages = + [ + ApplicationMessage.System("You are a helpful assistant."), + ApplicationMessage.User("你是谁?"), + ApplicationMessage.Assistant("我是阿里云开发的大规模语言模型,我叫通义千问。"), + ApplicationMessage.User("哪些人的主食偏好是米饭?"), + ], + }, + Parameters = new ApplicationParameters() + { + TopK = 100, + TopP = 0.8f, + Seed = 1234, + Temperature = 0.85f, + RagOptions = new ApplicationRagOptions() + { + PipelineIds = ["e6md69132k"], + StructuredFilter = new Dictionary { { "年龄", 14 } } + }, + HasThoughts = true + } + }, + new ApplicationResponse( + "d42335b3-fcb2-9d11-b651-29562ac02abe", + new ApplicationOutput( + "米饭作为主食,深受许多国家和地区人们的喜爱。以下是一些以米饭为主食的群体:\n\n1. **中国人**:尤其在南方地区,米饭是大多数家庭的主要食物。从广东、福建到四川、云南,米饭搭配各种菜肴构成了日常饮食的重要部分。\n\n2. **日本人**:日本料理中,白米饭占据核心地位,无论是便当中的小碗饭还是寿司的基础,都体现了米饭在日本饮食文化中的重要性。\n\n3. **韩国人**:韩国家庭餐桌上的“石锅拌饭”、“紫菜包饭”等经典菜品,反映了米饭在韩国饮食习惯里的不可或缺。\n\n4. **东南亚各国居民**(如泰国、越南、菲律宾、印尼等):这些地区的传统美食几乎都离不开米饭,像泰国香米更是闻名全球,成为该国饮食文化的象征之一。\n\n5. **印度及南亚次大陆部分地区人群**:虽然面饼(Roti/Naan)也很受欢迎,但米饭特别是与咖喱一起食用时,同样是众多印度家庭及其他南亚国家(如孟加拉国、斯里兰卡等)的重要主食选择。\n\n6. **中东部分国家的人们**:尽管面包可能是更普遍的选择,但在一些特定场合或日常饮食中,例如搭配烤肉、炖菜时,米饭同样被广泛使用。\n\n总体而言,由于其易于种植、营养丰富且能够很好地与其他食材结合的特点,米饭成为了上述地区人们世代相传的主要食物来源之一。", + "stop", + "9e2cf8c81f9a4fbe900a1f04b8522244", + [ + new ApplicationOutputThought( + null, + "agentRag", + "知识检索", + "rag", + "{}", + null, + "[{\"content\":\"【文档名】:用户食物偏好\\n名字:小明\\n主食偏好:面食\\n年龄:14\\n\",\"dataId\":\"table_df4b06e8931545b4b0a65e011087c197_10207234_1\",\"dataName\":\"用户食物偏好\",\"display\":true,\"id\":\"llm-lposod7dkhzvfgmy_e6md69132k_table_df4b06e8931545b4b0a65e011087c197_10207234_1\",\"referenceIndex\":1,\"score\":0.2185690850019455,\"webSearch\":false}]", + null, + "{}"), + new ApplicationOutputThought( + null, + "api", + "长期记忆检索", + "memory", + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"哪些人的主食偏好是米饭?\"}", + null, + "[]", + null, + "{\"memory_id\":\"ffd8be2352d84c6b9350e91c865b512e\",\"query\":\"哪些人的主食偏好是米饭?\"}") + ], + null), + new ApplicationUsage([new ApplicationModelUsage("qwen-plus", 344, 311)]))); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs new file mode 100644 index 0000000..eb4ea63 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Error.cs @@ -0,0 +1,105 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class Error + { + public static readonly + RequestSnapshot, DashScopeError> + AuthError = new( + "auth-error", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, + Parameters = new TextGenerationParameters + { + ResultFormat = "text", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = false + } + }, + new DashScopeError + { + Code = "InvalidApiKey", + Message = "Invalid API-key provided.", + RequestId = "a1c0561c-1dfe-98a6-a62f-983577b8bc5e" + }); + + public static readonly + RequestSnapshot, DashScopeError> + ParameterError = new( + "parameter-error", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "text", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = false + } + }, + new DashScopeError + { + Code = "InvalidParameter", + Message = "Role must be user or assistant and Content length must be greater than 0", + RequestId = "a5898c04-d210-901b-965f-e4bd90478805" + }); + + public static readonly + RequestSnapshot, DashScopeError> + ParameterErrorSse = new( + "parameter-error", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "text", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = true + } + }, + new DashScopeError + { + Code = "InvalidParameter", + Message = "Role must be user or assistant and Content length must be greater than 0", + RequestId = "7671ecd8-93cc-9ee9-bc89-739f0fd8b809" + }); + + public static readonly RequestSnapshot UploadErrorNoSse = new( + "upload-file-error", + new DashScopeError + { + Code = "invalid_request_error", + Message = "'purpose' must be 'file-extract'", + RequestId = string.Empty + }); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs new file mode 100644 index 0000000..20f17f5 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.MultimodalGeneration.cs @@ -0,0 +1,517 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class MultimodalGeneration + { + public static readonly RequestSnapshot, + ModelResponse> VlNoSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.System( + [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + ]) + ] + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + Temperature = 1.1f, + VlHighResolutionImages = true, + RepetitionPenalty = 1.3f, + PresencePenalty = 1.2f, + MaxTokens = 120, + Stop = "你好" + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent("海滩。") + ])) + ]), + RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", + Usage = new MultimodalTokenUsage + { + OutputTokens = 3, + InputTokens = 3613, + ImageTokens = 3577 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlChatClientNoSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + ]) + ] + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + Temperature = 1.1f, + RepetitionPenalty = 1.3f, + PresencePenalty = 1.2f, + MaxTokens = 120, + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent("海滩。") + ])) + ]), + RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", + Usage = new MultimodalTokenUsage + { + OutputTokens = 3, + InputTokens = 3613, + ImageTokens = 3577 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.System( + [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + ]) + ] + }, + Parameters = new MultimodalParameters + { + IncrementalOutput = true, + Seed = 1234, + TopK = 100, + TopP = 0.81f + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") + ])) + ]), + RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", + Usage = new MultimodalTokenUsage + { + OutputTokens = 85, + InputTokens = 1283, + ImageTokens = 1247 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> VlChatClientSse = + new( + "multimodal-generation-vl", + new ModelRequest + { + Model = "qwen-vl-plus", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), + MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") + ]) + ] + }, + Parameters = new MultimodalParameters + { + IncrementalOutput = true, + Seed = 1234, + TopK = 100, + TopP = 0.81f, + } + }, + new ModelResponse + { + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") + ])) + ]), + RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", + Usage = new MultimodalTokenUsage + { + OutputTokens = 85, + InputTokens = 1283, + ImageTokens = 1247 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + OcrNoSse = new( + "multimodal-generation-vl-ocr", + new ModelRequest + { + Model = "qwen-vl-ocr", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", + 3136, + 1003520), + MultimodalMessageContent.TextContent("Read all the text in the image.") + ]), + ] + }, + Parameters = new MultimodalParameters + { + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + MaxTokens = 2000, + TopP = 0.01f + } + }, + new ModelResponse + { + RequestId = "195c98cd-4ee5-998b-b662-132b7aebc048", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") + ])) + ]), + Usage = new MultimodalTokenUsage + { + InputTokens = 1248, + OutputTokens = 225, + ImageTokens = 1219 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + OcrSse = new( + "multimodal-generation-vl-ocr", + new ModelRequest + { + Model = "qwen-vl-ocr", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.ImageContent( + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", + 3136, + 1003520), + MultimodalMessageContent.TextContent("Read all the text in the image.") + ]), + ] + }, + Parameters = new MultimodalParameters + { + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + MaxTokens = 2000, + TopP = 0.01f, + IncrementalOutput = true + } + }, + new ModelResponse + { + RequestId = "fb33a990-3826-9386-8b0a-8317dfc38c1c", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") + ])) + ]), + Usage = new MultimodalTokenUsage + { + InputTokens = 1248, + OutputTokens = 225, + ImageTokens = 1219 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + AudioNoSse = new( + "multimodal-generation-audio", + new ModelRequest + { + Model = "qwen-audio-turbo", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.System( + [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), + MultimodalMessage.User( + [ + MultimodalMessageContent.AudioContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), + MultimodalMessageContent.TextContent("这段音频在说什么,请用简短的语言回答") + ]) + ] + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f + } + }, + new ModelResponse + { + RequestId = "6b6738bd-dd9d-9e78-958b-02574acbda44", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "这段音频在说中文,内容是\"没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网\"。") + ])) + ]), + Usage = new MultimodalTokenUsage + { + InputTokens = 786, + OutputTokens = 38, + AudioTokens = 752 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + AudioSse = new( + "multimodal-generation-audio", + new ModelRequest + { + Model = "qwen-audio-turbo", + Input = new MultimodalInput + { + Messages = + [ + MultimodalMessage.System( + [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), + MultimodalMessage.User( + [ + MultimodalMessageContent.AudioContent( + "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), + MultimodalMessageContent.TextContent("这段音频的第一句话说了什么?") + ]) + ] + }, + Parameters = new MultimodalParameters + { + Seed = 1234, + TopK = 100, + TopP = 0.81f, + IncrementalOutput = true + } + }, + new ModelResponse + { + RequestId = "bb6ab962-af57-99f1-9af8-eb7016ebc18e", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent("第一句话说了没有我互联网。") + ])) + ]), + Usage = new MultimodalTokenUsage + { + InputTokens = 783, + OutputTokens = 7, + AudioTokens = 752 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + VideoNoSse = new( + "multimodal-generation-vl-video", + new ModelRequest() + { + Model = "qwen-vl-max", + Input = new MultimodalInput() + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.VideoContent( + [ + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" + ]), + MultimodalMessageContent.TextContent("描述这个视频的具体过程") + ]), + ] + }, + Parameters = new MultimodalParameters() + { + Seed = 1234, + TopP = 0.01f, + Temperature = 0.1f, + RepetitionPenalty = 1.05f + } + }, + new ModelResponse() + { + RequestId = "d538f8cc-8048-9ca8-9e8a-d2a49985b479", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:球场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **守门员扑救**:守门员看到对方射门后,立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") + ])) + ]), + Usage = new MultimodalTokenUsage() + { + VideoTokens = 1440, + InputTokens = 1466, + OutputTokens = 180 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + VideoSse = new( + "multimodal-generation-vl-video", + new ModelRequest() + { + Model = "qwen-vl-max", + Input = new MultimodalInput() + { + Messages = + [ + MultimodalMessage.User( + [ + MultimodalMessageContent.VideoContent( + [ + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", + "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" + ]), + MultimodalMessageContent.TextContent("描述这个视频的具体过程") + ]), + ] + }, + Parameters = new MultimodalParameters() + { + Seed = 1234, + TopP = 0.01f, + Temperature = 0.1f, + RepetitionPenalty = 1.05f, + IncrementalOutput = true + } + }, + new ModelResponse() + { + RequestId = "851745a1-22ba-90e2-ace2-c04e7445ec6f", + Output = new MultimodalOutput( + [ + new MultimodalChoice( + "stop", + MultimodalMessage.Assistant( + [ + MultimodalMessageContent.TextContent( + "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **扑救尝试**:守门员看到射门后立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") + ])) + ]), + Usage = new MultimodalTokenUsage() + { + VideoTokens = 1440, + InputTokens = 1466, + OutputTokens = 176 + } + }); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs new file mode 100644 index 0000000..90b68ff --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.Tasks.cs @@ -0,0 +1,379 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class Tasks + { + public static readonly RequestSnapshot> + Unknown = new( + "get-task-unknown", + new DashScopeTask( + "85c25460-6440-91a7-b14e-2978fe60bd0f", + new BatchGetEmbeddingsOutput { TaskId = "1111", TaskStatus = DashScopeTaskStatus.Unknown })); + + public static readonly RequestSnapshot> + BatchEmbeddingSuccess = new( + "get-task-batch-text-embedding-success", + new DashScopeTask( + "0b2ebeda-a91b-948f-986a-d395cbf1d0e1", + new BatchGetEmbeddingsOutput + { + TaskId = "7408ef3d-a0be-4379-9e72-a6e95a569483", + TaskStatus = DashScopeTaskStatus.Succeeded, + Url = + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/5fc5c860/2024-11-25/c6c4456e-3c66-42ba-a52a-a16c58dda4d6_output_1732514147173.txt.gz?Expires=1732773347&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=perMNS1RdHHroUn2YnXxzTmOZtg%3D", + SubmitTime = new DateTime(2024, 11, 25, 13, 55, 46, 536), + ScheduledTime = new DateTime(2024, 11, 25, 13, 55, 46, 557), + EndTime = new DateTime(2024, 11, 25, 13, 55, 47, 446) + }, + new TextEmbeddingTokenUsage(28))); + + public static readonly RequestSnapshot> + ImageSynthesisRunning = + new( + "get-task-running", + new DashScopeTask( + "edbd4e81-d37b-97f1-9857-d7394829dd0f", + new ImageSynthesisOutput + { + TaskStatus = DashScopeTaskStatus.Running, + TaskId = "9e2b6ef6-285d-4efa-8651-4dbda7d571fa", + SubmitTime = new DateTime(2024, 3, 1, 17, 38, 24, 817), + ScheduledTime = new DateTime(2024, 3, 1, 17, 38, 24, 831), + TaskMetrics = new DashScopeTaskMetrics(4, 0, 0) + })); + + public static readonly RequestSnapshot> + ImageSynthesisSuccess = new( + "get-task-image-synthesis-success", + new DashScopeTask( + "6662e925-4846-9afe-a3af-0d131805d378", + new ImageSynthesisOutput + { + TaskId = "9e2b6ef6-285d-4efa-8651-4dbda7d571fa", + TaskStatus = DashScopeTaskStatus.Succeeded, + SubmitTime = new DateTime(2024, 3, 1, 17, 38, 24, 817), + ScheduledTime = new DateTime(2024, 3, 1, 17, 38, 24, 831), + EndTime = new DateTime(2024, 3, 1, 17, 38, 55, 565), + Results = + [ + new ImageSynthesisResult( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/1d/d4/20240301/8d820c8d/4c48fa53-2907-499b-b9ac-76477fe8d299-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=bEfLmd%2BarXgZyhxcVYOWs%2BovJb8%3D"), + new ImageSynthesisResult( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=fdPScmRkIXyH3TSaSaWwvVjxREQ%3D"), + new ImageSynthesisResult( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/0f/20240301/3ab595ad/ecfe06b3-b91c-4950-a932-49ea1619a1f9-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=gNuVAt8iy4X8Nl2l3K4Gu4f0ydw%3D"), + new ImageSynthesisResult( + "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/3d/20240301/3ab595ad/3fca748e-d491-458a-bb72-73649af33209-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=Mx5TueC9I9yfDno9rjzi48opHtM%3D") + ], + TaskMetrics = new DashScopeTaskMetrics(4, 4, 0) + }, + new ImageSynthesisUsage(4))); + + public static readonly RequestSnapshot> + ImageGenerationSuccess = new( + "get-task-image-generation-success", + new DashScopeTask( + "f927c766-5079-90f8-9354-6a87d2167897", + new ImageGenerationOutput + { + TaskId = "c4f94e00-5899-431b-9579-eb1ebe686379", + TaskStatus = DashScopeTaskStatus.Succeeded, + SubmitTime = new DateTime(2024, 3, 2, 22, 22, 13, 026), + ScheduledTime = new DateTime(2024, 3, 2, 22, 22, 13, 051), + EndTime = new DateTime(2024, 3, 2, 22, 22, 21), + StartTime = new DateTime(2024, 3, 2, 22, 22, 13), + StyleIndex = 3, + ErrorCode = 0, + ErrorMessage = "Success", + Results = + [ + new ImageGenerationResult( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/viapi-video/2024-03-02/ac5d435a-9ea9-4287-8666-e1be7bbba943/20240302222213528791_style3_jxdf6o4zwy.jpg?Expires=1709475741&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=LM26fy1Pk8rCfPzihzpUqa3Vst8%3D") + ] + }, + new ImageGenerationUsage(1))); + + public static readonly RequestSnapshot> + BackgroundGenerationSuccess = new( + "get-task-background-generation-success", + new DashScopeTask( + "8b22164d-c784-9a31-bda3-3c26259d4213", + new BackgroundGenerationOutput + { + TaskId = "b2e98d78-c79b-431c-b2d7-c7bcd54465da", + TaskStatus = DashScopeTaskStatus.Succeeded, + SubmitTime = new DateTime(2024, 3, 4, 10, 8, 57, 333), + ScheduledTime = new DateTime(2024, 3, 4, 10, 8, 57, 363), + EndTime = new DateTime(2024, 3, 4, 10, 9, 7, 727), + Results = + [ + new BackgroundGenerationResult( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_0_02dc0bba-8b1d-4648-8b95-eb2b92fe715d.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OYstgSxWOl%2FOxYTLa2Mx3bi2RWw%3D"), + new BackgroundGenerationResult( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_1_e1af86ec-152a-4ebe-b2a0-b40a592043b2.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=p0UXTUdXfp0tFlt0K5tDsA%2Fxl1M%3D") + ], + TaskMetrics = new DashScopeTaskMetrics(2, 2, 0), + TextResults = + new BackgroundGenerationTextResult( + [ + new BackgroundGenerationTextResultUrl( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=kmZGXc2s8P4uI%2BVrADITyrPz82U%3D"), + new BackgroundGenerationTextResultUrl( + "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=cb1Qg%2FkIuZyI7XQqWHjP712N0ak%3D") + ], + [ + new BackgroundGenerationTextResultParams( + 0, + [ + new BackgroundGenerationTextResultLayer( + 0, + "text_mask", + 0, + 0, + 1024, + 257, + Color: "#521b08", + Opacity: 0.8f, + Radius: 0, + Gradient: new BackgroundGenerationTextResultGradient( + "linear", + "pixels", + [ + new BackgroundGenerationTextResultGradientColorStop( + "#521b0800", + 0), + new BackgroundGenerationTextResultGradientColorStop( + "#521b08ff", + 1) + ]) + { + Coords = new Dictionary + { + { "y1", 257 }, + { "x1", 0 }, + { "y2", 0 }, + { "x2", 0 } + } + }), + new BackgroundGenerationTextResultLayer( + 1, + "text", + 25, + 319, + 385, + 77, + SubType: "Title", + FontWeight: "Regular", + FontSize: 67, + Content: "分享好时光", + FontUnderLine: false, + LineHeight: 1f, + FontItalic: false, + FontColor: "#e6baa7", + TextShadow: "1px 0px #80808080", + TextStroke: "1px #fffffff0", + FontFamily: "站酷文艺体", + Alignment: "center", + FontLineThrough: false, + Direction: "horizontal", + Opacity: 1f), + new BackgroundGenerationTextResultLayer( + 2, + "text_mask", + 118, + 395, + 233, + 50, + Color: "#e6baa7", + Opacity: 1f, + Radius: 37, + BoxShadow: "2px 1px #80808080", + Gradient: new BackgroundGenerationTextResultGradient( + "linear", + "pixels", + [ + new BackgroundGenerationTextResultGradientColorStop( + "#e6baa7ff", + 0), + new BackgroundGenerationTextResultGradientColorStop( + "#e6baa7ff", + 1) + ]) + { + Coords = new Dictionary + { + { "y1", 0 }, + { "x1", 0 }, + { "y2", 50 }, + { "x2", 0 } + } + }), + new BackgroundGenerationTextResultLayer( + 3, + "text", + 118, + 395, + 233, + 50, + FontWeight: "Medium", + FontSize: 27, + Content: "只为不一样的你", + FontUnderLine: false, + LineHeight: 1f, + FontItalic: false, + SubType: "SubTitle", + FontColor: "#223629", + TextShadow: null, + FontFamily: "阿里巴巴普惠体", + Alignment: "center", + Opacity: 1f, + FontLineThrough: false, + Direction: "horizontal") + ]), + new BackgroundGenerationTextResultParams( + 1, + [ + new BackgroundGenerationTextResultLayer( + 0, + "text_mask", + 0, + 0, + 1024, + 257, + Color: "#efeae4", + Gradient: new BackgroundGenerationTextResultGradient( + "linear", + "pixels", + [ + new BackgroundGenerationTextResultGradientColorStop( + "#efeae400", + 0), + new BackgroundGenerationTextResultGradientColorStop( + "#efeae4ff", + 1) + ]) + { + Coords = new Dictionary + { + { "y1", 257 }, + { "x1", 0 }, + { "y2", 0 }, + { "x2", 0 } + } + }, + Opacity: 0.8f, + Radius: 0), + new BackgroundGenerationTextResultLayer( + 1, + "text", + 25, + 319, + 385, + 77, + SubType: "Title", + Content: "分享好时光", + FontWeight: "Regular", + FontSize: 67, + FontUnderLine: false, + LineHeight: 1f, + FontItalic: false, + FontColor: "#421f12", + TextStroke: "1px #fffffff0", + TextShadow: "0px 2px #80808080", + FontFamily: "钉钉进步体", + Alignment: "center", + Opacity: 1f, + FontLineThrough: false, + Direction: "horizontal"), + new BackgroundGenerationTextResultLayer( + 2, + "text_mask", + 118, + 395, + 233, + 50, + Color: "#421f12", + Gradient: new BackgroundGenerationTextResultGradient( + "linear", + "pixels", + [ + new BackgroundGenerationTextResultGradientColorStop( + "#421f12ff", + 0), + new BackgroundGenerationTextResultGradientColorStop( + "#421f12ff", + 1) + ]) + { + Coords = new Dictionary + { + { "y1", 0 }, + { "x1", 0 }, + { "y2", 50 }, + { "x2", 0 } + } + }, + Opacity: 1f, + Radius: 37, + BoxShadow: "0px 0px #80808080"), + new BackgroundGenerationTextResultLayer( + 3, + "text", + 118, + 395, + 233, + 50, + FontWeight: "Regular", + FontSize: 27, + Content: "只为不一样的你", + FontUnderLine: false, + LineHeight: 1, + FontItalic: false, + SubType: "SubTitle", + FontColor: "#f1eeec", + TextShadow: null, + FontFamily: "阿里巴巴普惠体", + Alignment: "center", + Opacity: 1, + FontLineThrough: false, + Direction: "horizontal") + ]) + ]) + }, + new BackgroundGenerationUsage(2))); + + public static readonly RequestSnapshot CancelCompletedTask = new( + "cancel-completed-task", + new DashScopeTaskOperationResponse( + "4d496c94-1389-9ca9-a92a-3e732f675686", + "UnsupportedOperation", + "Failed to cancel the task, please confirm if the task is in PENDING status.")); + + public static readonly RequestSnapshot ListTasks = new( + "list-task", + new DashScopeTaskList( + "fcb29ae5-a352-9e7b-901c-e53525376cde", + [ + new DashScopeTaskListItem( + "42677", + "1493478651020171", + "1493478651020171", + 1709260684485, + 1709260684527, + 1709260685184, + "cn-beijing", + "db5ce040-4548-9919-9a75-3385ee152335", + DashScopeTaskStatus.Succeeded, + "6075262c-b56d-4968-9abf-2a9784a90f3e", + "apikey:v1:embeddings:text-embedding:text-embedding:text-embedding-async-v2", + "text-embedding-async-v2") + ], + 1, + 1, + 1, + 10)); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextEmbedding.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextEmbedding.cs new file mode 100644 index 0000000..bbfa68f --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextEmbedding.cs @@ -0,0 +1,65 @@ +using Cnblogs.DashScope.Core; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class TextEmbedding + { + public static readonly RequestSnapshot, + ModelResponse> NoSse = new( + "text-embedding", + new ModelRequest + { + Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, + Model = "text-embedding-v2", + Parameters = new TextEmbeddingParameters { TextType = "query" } + }, + new ModelResponse + { + Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), + RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", + Usage = new TextEmbeddingTokenUsage(3) + }); + + public static readonly RequestSnapshot, + ModelResponse> EmbeddingClientNoSse = new( + "text-embedding", + new ModelRequest + { + Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, + Model = "text-embedding-v3", + Parameters = new TextEmbeddingParameters { Dimension = 1024 } + }, + new ModelResponse + { + Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), + RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", + Usage = new TextEmbeddingTokenUsage(3) + }); + + public static readonly + RequestSnapshot, + ModelResponse> BatchNoSse = new( + "batch-text-embedding", + new ModelRequest + { + Input = new BatchGetEmbeddingsInput + { + Url = + "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/text_embedding_file.txt" + }, + Model = "text-embedding-async-v2", + Parameters = new BatchGetEmbeddingsParameters { TextType = "query" } + }, + new ModelResponse + { + RequestId = "db5ce040-4548-9919-9a75-3385ee152335", + Output = new BatchGetEmbeddingsOutput + { + TaskId = "6075262c-b56d-4968-9abf-2a9784a90f3e", + TaskStatus = DashScopeTaskStatus.Pending + } + }); + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs new file mode 100644 index 0000000..6f8fe94 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.TextGeneration.cs @@ -0,0 +1,614 @@ +using Cnblogs.DashScope.Core; +using Json.Schema; +using Json.Schema.Generation; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public static partial class Snapshots +{ + public static class TextGeneration + { + public static class TextFormat + { + public static readonly RequestSnapshot, + ModelResponse> + SinglePrompt = new( + "single-generation-text", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, + Parameters = new TextGenerationParameters + { + ResultFormat = "text", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = false + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + FinishReason = "stop", Text = "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下两个一相加的结果都是二。" + }, + RequestId = "4ef2ed16-4dc3-9083-a723-fb2e80c84d3b", + Usage = new TextGenerationTokenUsage + { + InputTokens = 8, + OutputTokens = 35, + TotalTokens = 43 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + SinglePromptIncremental = new( + "single-generation-text", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, + Parameters = new TextGenerationParameters + { + ResultFormat = "text", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = true + } + }, + new ModelResponse + { + Output = new TextGenerationOutput { FinishReason = "stop", Text = "1+1等于2。" }, + RequestId = "5b441aa7-0b9c-9fbc-ae0a-e2b212b71eac", + Usage = new TextGenerationTokenUsage + { + InputTokens = 16, + OutputTokens = 6, + TotalTokens = 22 + } + }); + } + + public static class MessageFormat + { + public static readonly RequestSnapshot, + ModelResponse> + SingleMessage = new( + "single-generation-message", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = false + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + } + ] + }, + RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 47, + OutputTokens = 39, + InputTokens = 8 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + SingleChatClientMessage = new( + "single-generation-message", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + ToolChoice = ToolChoice.AutoChoice + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") + } + ] + }, + RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 47, + OutputTokens = 39, + InputTokens = 8 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + SingleMessageJson = new( + "single-generation-message-json", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?用 JSON 格式输出。")] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = false, + ResponseFormat = DashScopeResponseFormat.Json + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant("{\n \"result\": 2\n}") + } + ] + }, + RequestId = "6af9571b-1033-98f9-a287-c06f2e9d6f7f", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 34, + OutputTokens = 9, + InputTokens = 25 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + SingleMessageIncremental = new( + "single-generation-message", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = true + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + } + ] + }, + RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 48, + OutputTokens = 40, + InputTokens = 8 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + SingleMessageChatClientIncremental = new( + "single-generation-message", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new[] { "你好" }, + IncrementalOutput = true, + ToolChoice = ToolChoice.AutoChoice + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") + } + ] + }, + RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 48, + OutputTokens = 40, + InputTokens = 8 + } + }); + + public static readonly + RequestSnapshot, + ModelResponse> SingleMessageWithTools = + new( + "single-generation-message-with-tools", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, + Parameters = new TextGenerationParameters() + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + PresencePenalty = 1.2f, + Temperature = 0.85f, + Stop = new TextGenerationStop("你好"), + EnableSearch = false, + IncrementalOutput = false, + Tools = + [ + new ToolDefinition( + "function", + new FunctionDefinition( + "get_current_weather", + "获取现在的天气", + new JsonSchemaBuilder().FromType( + new SchemaGeneratorConfiguration + { + PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase + }) + .Build())) + ], + ToolChoice = ToolChoice.FunctionChoice("get_current_weather") + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + string.Empty, + toolCalls: + [ + new ToolCall( + "call_cec4c19d27624537b583af", + ToolTypes.Function, + 0, + new FunctionCall( + "get_current_weather", + """{"location": "浙江省杭州市"}""")) + ]) + } + ] + }, + RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", + Usage = new TextGenerationTokenUsage + { + InputTokens = 211, + OutputTokens = 8, + TotalTokens = 219 + } + }); + + public static readonly + RequestSnapshot, + ModelResponse> SingleMessageChatClientWithTools = + new( + "single-generation-message-with-tools", + new ModelRequest + { + Model = "qwen-max", + Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, + Parameters = new TextGenerationParameters() + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + PresencePenalty = 1.2f, + Temperature = 0.85f, + Tools = + [ + new ToolDefinition( + "function", + new FunctionDefinition( + "get_current_weather", + "获取现在的天气", + new JsonSchemaBuilder().FromType( + new SchemaGeneratorConfiguration + { + PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase + }) + .Build())) + ], + ToolChoice = ToolChoice.FunctionChoice("get_current_weather") + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + string.Empty, + toolCalls: + [ + new ToolCall( + "call_cec4c19d27624537b583af", + ToolTypes.Function, + 0, + new FunctionCall( + "get_current_weather", + """{"location": "浙江省杭州市"}""")) + ]) + } + ] + }, + RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", + Usage = new TextGenerationTokenUsage + { + InputTokens = 211, + OutputTokens = 8, + TotalTokens = 219 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + ConversationPartialMessageNoSse = new( + "conversation-generation-message-partial", + new ModelRequest() + { + Model = "qwen-max", + Input = new TextGenerationInput() + { + Messages = + [ + TextChatMessage.User("请对“春天来了,大地”这句话进行续写,来表达春天的美好和作者的喜悦之情"), + TextChatMessage.Assistant("春天来了,大地", true) + ] + }, + Parameters = new TextGenerationParameters() + { + ResultFormat = ResultFormats.Message, + Seed = 1234, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false + } + }, + new ModelResponse() + { + RequestId = "4c45d7fd-3158-9ff4-96a0-6e92c710df2c", + Output = new TextGenerationOutput() + { + Choices = + [ + new TextGenerationChoice() + { + FinishReason = "stop", + Message = + TextChatMessage.Assistant( + "仿佛从漫长的冬眠中苏醒过来,万物复苏。嫩绿的小草悄悄地探出了头,争先恐后地想要沐浴在温暖的阳光下;五彩斑斓的花朵也不甘示弱,竞相绽放着自己最美丽的姿态,将田野、山林装扮得分外妖娆。微风轻轻吹过,带来了泥土的气息与花香混合的独特香味,让人心旷神怡。小鸟们开始忙碌起来,在枝头欢快地歌唱,似乎也在庆祝这个充满希望的新季节的到来。这一切美好景象不仅让人感受到了大自然的魅力所在,更激发了人们对生活无限热爱和向往的心情。") + } + ] + }, + Usage = new TextGenerationTokenUsage() + { + TotalTokens = 165, + OutputTokens = 131, + InputTokens = 34 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + ConversationMessageIncremental = new( + "conversation-generation-message", + new ModelRequest + { + Model = "qwen-max", + Input = + new TextGenerationInput + { + Messages = + [ + TextChatMessage.User("现在请你记住一个数字,42"), + TextChatMessage.Assistant("好的,我已经记住了这个数字。"), + TextChatMessage.User("请问我刚才提到的数字是多少?") + ] + }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = true + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", Message = TextChatMessage.Assistant("您刚才提到的数字是42。") + } + ] + }, + RequestId = "9188e907-56c2-9849-97f6-23f130f7fed7", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 33, + OutputTokens = 9, + InputTokens = 24 + } + }); + + public static readonly RequestSnapshot, + ModelResponse> + ConversationMessageWithFilesIncremental = new( + "conversation-generation-message-with-files", + new ModelRequest + { + Model = "qwen-long", + Input = + new TextGenerationInput + { + Messages = + [ + TextChatMessage.File( + ["file-fe-WTTG89tIUTd4ByqP3K48R3bn", "file-fe-l92iyRvJm9vHCCfonLckf1o2"]), + TextChatMessage.User("这两个文件是相同的吗?") + ] + }, + Parameters = new TextGenerationParameters + { + ResultFormat = "message", + Seed = 1234, + MaxTokens = 1500, + TopP = 0.8f, + TopK = 100, + RepetitionPenalty = 1.1f, + Temperature = 0.85f, + Stop = new int[][] { [37763, 367] }, + EnableSearch = false, + IncrementalOutput = true + } + }, + new ModelResponse + { + Output = new TextGenerationOutput + { + Choices = + [ + new TextGenerationChoice + { + FinishReason = "stop", + Message = TextChatMessage.Assistant( + "你上传的两个文件并不相同。第一个文件`test1.txt`包含两行文本,每行都是“测试”。而第二个文件`test2.txt`只有一行文本,“测试2”。尽管它们都含有“测试”这个词,但具体内容和结构不同。") + } + ] + }, + RequestId = "7865ae43-8379-9c79-bef6-95050868bc52", + Usage = new TextGenerationTokenUsage + { + TotalTokens = 115, + OutputTokens = 57, + InputTokens = 58 + } + }); + } + } +} diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs index fec5a40..ab61622 100644 --- a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/Snapshots.cs @@ -1,1286 +1,9 @@ using Cnblogs.DashScope.Core; -using Json.Schema; -using Json.Schema.Generation; namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; -public static class Snapshots +public static partial class Snapshots { - public static class Error - { - public static readonly - RequestSnapshot, DashScopeError> - AuthError = new( - "auth-error", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, - Parameters = new TextGenerationParameters - { - ResultFormat = "text", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = false - } - }, - new DashScopeError - { - Code = "InvalidApiKey", - Message = "Invalid API-key provided.", - RequestId = "a1c0561c-1dfe-98a6-a62f-983577b8bc5e" - }); - - public static readonly - RequestSnapshot, DashScopeError> - ParameterError = new( - "parameter-error", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "text", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = false - } - }, - new DashScopeError - { - Code = "InvalidParameter", - Message = "Role must be user or assistant and Content length must be greater than 0", - RequestId = "a5898c04-d210-901b-965f-e4bd90478805" - }); - - public static readonly - RequestSnapshot, DashScopeError> - ParameterErrorSse = new( - "parameter-error", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?", Messages = [] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "text", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = true - } - }, - new DashScopeError - { - Code = "InvalidParameter", - Message = "Role must be user or assistant and Content length must be greater than 0", - RequestId = "7671ecd8-93cc-9ee9-bc89-739f0fd8b809" - }); - - public static readonly RequestSnapshot UploadErrorNoSse = new( - "upload-file-error", - new DashScopeError - { - Code = "invalid_request_error", - Message = "'purpose' must be 'file-extract'", - RequestId = string.Empty - }); - } - - public static class TextGeneration - { - public static class TextFormat - { - public static readonly RequestSnapshot, - ModelResponse> - SinglePrompt = new( - "single-generation-text", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, - Parameters = new TextGenerationParameters - { - ResultFormat = "text", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = false - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - FinishReason = "stop", Text = "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下两个一相加的结果都是二。" - }, - RequestId = "4ef2ed16-4dc3-9083-a723-fb2e80c84d3b", - Usage = new TextGenerationTokenUsage - { - InputTokens = 8, - OutputTokens = 35, - TotalTokens = 43 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - SinglePromptIncremental = new( - "single-generation-text", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Prompt = "请问 1+1 是多少?" }, - Parameters = new TextGenerationParameters - { - ResultFormat = "text", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = true - } - }, - new ModelResponse - { - Output = new TextGenerationOutput { FinishReason = "stop", Text = "1+1等于2。" }, - RequestId = "5b441aa7-0b9c-9fbc-ae0a-e2b212b71eac", - Usage = new TextGenerationTokenUsage - { - InputTokens = 16, - OutputTokens = 6, - TotalTokens = 22 - } - }); - } - - public static class MessageFormat - { - public static readonly RequestSnapshot, - ModelResponse> - SingleMessage = new( - "single-generation-message", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = false - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") - } - ] - }, - RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 47, - OutputTokens = 39, - InputTokens = 8 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - SingleChatClientMessage = new( - "single-generation-message", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - ToolChoice = ToolChoice.AutoChoice - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何两个相同的数字相加都等于该数字的二倍。") - } - ] - }, - RequestId = "e764bfe3-c0b7-97a0-ae57-cd99e1580960", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 47, - OutputTokens = 39, - InputTokens = 8 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - SingleMessageJson = new( - "single-generation-message-json", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?用 JSON 格式输出。")] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = false, - ResponseFormat = DashScopeResponseFormat.Json - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant("{\n \"result\": 2\n}") - } - ] - }, - RequestId = "6af9571b-1033-98f9-a287-c06f2e9d6f7f", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 34, - OutputTokens = 9, - InputTokens = 25 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - SingleMessageIncremental = new( - "single-generation-message", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = true - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") - } - ] - }, - RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 48, - OutputTokens = 40, - InputTokens = 8 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - SingleMessageChatClientIncremental = new( - "single-generation-message", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput { Messages = [TextChatMessage.User("请问 1+1 是多少?")] }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new[] { "你好" }, - IncrementalOutput = true, - ToolChoice = ToolChoice.AutoChoice - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "1+1 等于 2。这是最基本的数学加法之一,在十进制计数体系中,任何情况下 1 加上另一个 1 的结果都是 2。") - } - ] - }, - RequestId = "d272255f-82d7-9cc7-93c5-17ff77024349", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 48, - OutputTokens = 40, - InputTokens = 8 - } - }); - - public static readonly - RequestSnapshot, - ModelResponse> SingleMessageWithTools = - new( - "single-generation-message-with-tools", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, - Parameters = new TextGenerationParameters() - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - PresencePenalty = 1.2f, - Temperature = 0.85f, - Stop = new TextGenerationStop("你好"), - EnableSearch = false, - IncrementalOutput = false, - Tools = - [ - new ToolDefinition( - "function", - new FunctionDefinition( - "get_current_weather", - "获取现在的天气", - new JsonSchemaBuilder().FromType( - new SchemaGeneratorConfiguration - { - PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase - }) - .Build())) - ], - ToolChoice = ToolChoice.FunctionChoice("get_current_weather") - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - string.Empty, - toolCalls: - [ - new ToolCall( - "call_cec4c19d27624537b583af", - ToolTypes.Function, - 0, - new FunctionCall( - "get_current_weather", - """{"location": "浙江省杭州市"}""")) - ]) - } - ] - }, - RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", - Usage = new TextGenerationTokenUsage - { - InputTokens = 211, - OutputTokens = 8, - TotalTokens = 219 - } - }); - - public static readonly - RequestSnapshot, - ModelResponse> SingleMessageChatClientWithTools = - new( - "single-generation-message-with-tools", - new ModelRequest - { - Model = "qwen-max", - Input = new TextGenerationInput { Messages = [TextChatMessage.User("杭州现在的天气如何?")] }, - Parameters = new TextGenerationParameters() - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - PresencePenalty = 1.2f, - Temperature = 0.85f, - Tools = - [ - new ToolDefinition( - "function", - new FunctionDefinition( - "get_current_weather", - "获取现在的天气", - new JsonSchemaBuilder().FromType( - new SchemaGeneratorConfiguration - { - PropertyNameResolver = PropertyNameResolvers.LowerSnakeCase - }) - .Build())) - ], - ToolChoice = ToolChoice.FunctionChoice("get_current_weather") - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - string.Empty, - toolCalls: - [ - new ToolCall( - "call_cec4c19d27624537b583af", - ToolTypes.Function, - 0, - new FunctionCall( - "get_current_weather", - """{"location": "浙江省杭州市"}""")) - ]) - } - ] - }, - RequestId = "67300049-c108-9987-b1c1-8e0ee2de6b5d", - Usage = new TextGenerationTokenUsage - { - InputTokens = 211, - OutputTokens = 8, - TotalTokens = 219 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - ConversationPartialMessageNoSse = new( - "conversation-generation-message-partial", - new ModelRequest() - { - Model = "qwen-max", - Input = new TextGenerationInput() - { - Messages = - [ - TextChatMessage.User("请对“春天来了,大地”这句话进行续写,来表达春天的美好和作者的喜悦之情"), - TextChatMessage.Assistant("春天来了,大地", true) - ] - }, - Parameters = new TextGenerationParameters() - { - ResultFormat = ResultFormats.Message, - Seed = 1234, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false - } - }, - new ModelResponse() - { - RequestId = "4c45d7fd-3158-9ff4-96a0-6e92c710df2c", - Output = new TextGenerationOutput() - { - Choices = - [ - new TextGenerationChoice() - { - FinishReason = "stop", - Message = - TextChatMessage.Assistant( - "仿佛从漫长的冬眠中苏醒过来,万物复苏。嫩绿的小草悄悄地探出了头,争先恐后地想要沐浴在温暖的阳光下;五彩斑斓的花朵也不甘示弱,竞相绽放着自己最美丽的姿态,将田野、山林装扮得分外妖娆。微风轻轻吹过,带来了泥土的气息与花香混合的独特香味,让人心旷神怡。小鸟们开始忙碌起来,在枝头欢快地歌唱,似乎也在庆祝这个充满希望的新季节的到来。这一切美好景象不仅让人感受到了大自然的魅力所在,更激发了人们对生活无限热爱和向往的心情。") - } - ] - }, - Usage = new TextGenerationTokenUsage() - { - TotalTokens = 165, - OutputTokens = 131, - InputTokens = 34 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - ConversationMessageIncremental = new( - "conversation-generation-message", - new ModelRequest - { - Model = "qwen-max", - Input = - new TextGenerationInput - { - Messages = - [ - TextChatMessage.User("现在请你记住一个数字,42"), - TextChatMessage.Assistant("好的,我已经记住了这个数字。"), - TextChatMessage.User("请问我刚才提到的数字是多少?") - ] - }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = true - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", Message = TextChatMessage.Assistant("您刚才提到的数字是42。") - } - ] - }, - RequestId = "9188e907-56c2-9849-97f6-23f130f7fed7", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 33, - OutputTokens = 9, - InputTokens = 24 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - ConversationMessageWithFilesIncremental = new( - "conversation-generation-message-with-files", - new ModelRequest - { - Model = "qwen-long", - Input = - new TextGenerationInput - { - Messages = - [ - TextChatMessage.File( - ["file-fe-WTTG89tIUTd4ByqP3K48R3bn", "file-fe-l92iyRvJm9vHCCfonLckf1o2"]), - TextChatMessage.User("这两个文件是相同的吗?") - ] - }, - Parameters = new TextGenerationParameters - { - ResultFormat = "message", - Seed = 1234, - MaxTokens = 1500, - TopP = 0.8f, - TopK = 100, - RepetitionPenalty = 1.1f, - Temperature = 0.85f, - Stop = new int[][] { [37763, 367] }, - EnableSearch = false, - IncrementalOutput = true - } - }, - new ModelResponse - { - Output = new TextGenerationOutput - { - Choices = - [ - new TextGenerationChoice - { - FinishReason = "stop", - Message = TextChatMessage.Assistant( - "你上传的两个文件并不相同。第一个文件`test1.txt`包含两行文本,每行都是“测试”。而第二个文件`test2.txt`只有一行文本,“测试2”。尽管它们都含有“测试”这个词,但具体内容和结构不同。") - } - ] - }, - RequestId = "7865ae43-8379-9c79-bef6-95050868bc52", - Usage = new TextGenerationTokenUsage - { - TotalTokens = 115, - OutputTokens = 57, - InputTokens = 58 - } - }); - } - } - - public static class MultimodalGeneration - { - public static readonly RequestSnapshot, - ModelResponse> VlNoSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - Temperature = 1.1f, - VlHighResolutionImages = true, - RepetitionPenalty = 1.3f, - PresencePenalty = 1.2f, - MaxTokens = 120, - Stop = "你好" - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("海滩。") - ])) - ]), - RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", - Usage = new MultimodalTokenUsage - { - OutputTokens = 3, - InputTokens = 3613, - ImageTokens = 3577 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlChatClientNoSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - Temperature = 1.1f, - RepetitionPenalty = 1.3f, - PresencePenalty = 1.2f, - MaxTokens = 120, - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("海滩。") - ])) - ]), - RequestId = "e81aa922-be6c-9f9d-bd4f-0f43e21fd913", - Usage = new MultimodalTokenUsage - { - OutputTokens = 3, - InputTokens = 3613, - ImageTokens = 3577 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/images/dog_and_girl.jpeg"), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - IncrementalOutput = true, - Seed = 1234, - TopK = 100, - TopP = 0.81f - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") - ])) - ]), - RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", - Usage = new MultimodalTokenUsage - { - OutputTokens = 85, - InputTokens = 1283, - ImageTokens = 1247 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> VlChatClientSse = - new( - "multimodal-generation-vl", - new ModelRequest - { - Model = "qwen-vl-plus", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="), - MultimodalMessageContent.TextContent("这个图片是哪里,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - IncrementalOutput = true, - Seed = 1234, - TopK = 100, - TopP = 0.81f, - } - }, - new ModelResponse - { - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这是一个海滩,有沙滩和海浪。在前景中坐着一个女人与她的宠物狗互动。背景中有海水、阳光及远处的海岸线。由于没有具体标识物或地标信息,我无法提供更精确的位置描述。这可能是一个公共海滩或是私人区域。重要的是要注意不要泄露任何个人隐私,并遵守当地的规定和法律法规。欣赏自然美景的同时请尊重环境和其他访客。") - ])) - ]), - RequestId = "13c5644d-339c-928a-a09a-e0414bfaa95c", - Usage = new MultimodalTokenUsage - { - OutputTokens = 85, - InputTokens = 1283, - ImageTokens = 1247 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - OcrNoSse = new( - "multimodal-generation-vl-ocr", - new ModelRequest - { - Model = "qwen-vl-ocr", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", - 3136, - 1003520), - MultimodalMessageContent.TextContent("Read all the text in the image.") - ]), - ] - }, - Parameters = new MultimodalParameters - { - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - MaxTokens = 2000, - TopP = 0.01f - } - }, - new ModelResponse - { - RequestId = "195c98cd-4ee5-998b-b662-132b7aebc048", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 1248, - OutputTokens = 225, - ImageTokens = 1219 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - OcrSse = new( - "multimodal-generation-vl-ocr", - new ModelRequest - { - Model = "qwen-vl-ocr", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.ImageContent( - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg", - 3136, - 1003520), - MultimodalMessageContent.TextContent("Read all the text in the image.") - ]), - ] - }, - Parameters = new MultimodalParameters - { - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - MaxTokens = 2000, - TopP = 0.01f, - IncrementalOutput = true - } - }, - new ModelResponse - { - RequestId = "fb33a990-3826-9386-8b0a-8317dfc38c1c", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "读者对象 如果你是Linux环境下的系统管理员,那么学会编写shell脚本将让你受益匪浅。本书并未细述安装 Linux系统的每个步骤,但只要系统已安装好Linux并能运行起来,你就可以开始考虑如何让一些日常 的系统管理任务实现自动化。这时shell脚本编程就能发挥作用了,这也正是本书的作用所在。本书将 演示如何使用shell脚本来自动处理系统管理任务,包括从监测系统统计数据和数据文件到为你的老板 生成报表。 如果你是家用Linux爱好者,同样能从本书中获益。现今,用户很容易在诸多部件堆积而成的图形环境 中迷失。大多数桌面Linux发行版都尽量向一般用户隐藏系统的内部细节。但有时你确实需要知道内部 发生了什么。本书将告诉你如何启动Linux命令行以及接下来要做什么。通常,如果是执行一些简单任 务(比如文件管理) , 在命令行下操作要比在华丽的图形界面下方便得多。在命令行下有大量的命令 可供使用,本书将会展示如何使用它们。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 1248, - OutputTokens = 225, - ImageTokens = 1219 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - AudioNoSse = new( - "multimodal-generation-audio", - new ModelRequest - { - Model = "qwen-audio-turbo", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.AudioContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), - MultimodalMessageContent.TextContent("这段音频在说什么,请用简短的语言回答") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f - } - }, - new ModelResponse - { - RequestId = "6b6738bd-dd9d-9e78-958b-02574acbda44", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段音频在说中文,内容是\"没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网未来没有我互联网\"。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 786, - OutputTokens = 38, - AudioTokens = 752 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - AudioSse = new( - "multimodal-generation-audio", - new ModelRequest - { - Model = "qwen-audio-turbo", - Input = new MultimodalInput - { - Messages = - [ - MultimodalMessage.System( - [MultimodalMessageContent.TextContent("You are a helpful assistant.")]), - MultimodalMessage.User( - [ - MultimodalMessageContent.AudioContent( - "https://dashscope.oss-cn-beijing.aliyuncs.com/audios/2channel_16K.wav"), - MultimodalMessageContent.TextContent("这段音频的第一句话说了什么?") - ]) - ] - }, - Parameters = new MultimodalParameters - { - Seed = 1234, - TopK = 100, - TopP = 0.81f, - IncrementalOutput = true - } - }, - new ModelResponse - { - RequestId = "bb6ab962-af57-99f1-9af8-eb7016ebc18e", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent("第一句话说了没有我互联网。") - ])) - ]), - Usage = new MultimodalTokenUsage - { - InputTokens = 783, - OutputTokens = 7, - AudioTokens = 752 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - VideoNoSse = new( - "multimodal-generation-vl-video", - new ModelRequest() - { - Model = "qwen-vl-max", - Input = new MultimodalInput() - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.VideoContent( - [ - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" - ]), - MultimodalMessageContent.TextContent("描述这个视频的具体过程") - ]), - ] - }, - Parameters = new MultimodalParameters() - { - Seed = 1234, - TopP = 0.01f, - Temperature = 0.1f, - RepetitionPenalty = 1.05f - } - }, - new ModelResponse() - { - RequestId = "d538f8cc-8048-9ca8-9e8a-d2a49985b479", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:球场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **守门员扑救**:守门员看到对方射门后,立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") - ])) - ]), - Usage = new MultimodalTokenUsage() - { - VideoTokens = 1440, - InputTokens = 1466, - OutputTokens = 180 - } - }); - - public static readonly RequestSnapshot, - ModelResponse> - VideoSse = new( - "multimodal-generation-vl-video", - new ModelRequest() - { - Model = "qwen-vl-max", - Input = new MultimodalInput() - { - Messages = - [ - MultimodalMessage.User( - [ - MultimodalMessageContent.VideoContent( - [ - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg", - "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg" - ]), - MultimodalMessageContent.TextContent("描述这个视频的具体过程") - ]), - ] - }, - Parameters = new MultimodalParameters() - { - Seed = 1234, - TopP = 0.01f, - Temperature = 0.1f, - RepetitionPenalty = 1.05f, - IncrementalOutput = true - } - }, - new ModelResponse() - { - RequestId = "851745a1-22ba-90e2-ace2-c04e7445ec6f", - Output = new MultimodalOutput( - [ - new MultimodalChoice( - "stop", - MultimodalMessage.Assistant( - [ - MultimodalMessageContent.TextContent( - "这段视频展示了一场足球比赛的精彩瞬间。具体过程如下:\n\n1. **背景**:画面中是一个大型体育场,观众席上坐满了观众,气氛热烈。\n2. **球员位置**:场上有两队球员,一队穿着红色球衣,另一队穿着蓝色球衣。守门员穿着绿色球衣,站在球门前准备防守。\n3. **射门动作**:一名身穿红色球衣的球员在禁区内接到队友传球后,迅速起脚射门。\n4. **扑救尝试**:守门员看到射门后立即做出反应,向左侧跃出试图扑救。\n5. **进球瞬间**:尽管守门员尽力扑救,但皮球还是从他的右侧飞入了球网。\n\n整个过程充满了紧张和刺激,展示了足球比赛中的精彩时刻。") - ])) - ]), - Usage = new MultimodalTokenUsage() - { - VideoTokens = 1440, - InputTokens = 1466, - OutputTokens = 176 - } - }); - } - - public static class TextEmbedding - { - public static readonly RequestSnapshot, - ModelResponse> NoSse = new( - "text-embedding", - new ModelRequest - { - Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, - Model = "text-embedding-v2", - Parameters = new TextEmbeddingParameters { TextType = "query" } - }, - new ModelResponse - { - Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), - RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", - Usage = new TextEmbeddingTokenUsage(3) - }); - - public static readonly RequestSnapshot, - ModelResponse> EmbeddingClientNoSse = new( - "text-embedding", - new ModelRequest - { - Input = new TextEmbeddingInput { Texts = ["代码改变世界"] }, - Model = "text-embedding-v3", - Parameters = new TextEmbeddingParameters { Dimension = 1024 } - }, - new ModelResponse - { - Output = new TextEmbeddingOutput([new TextEmbeddingItem(0, [])]), - RequestId = "1773f7b2-2148-9f74-b335-b413e398a116", - Usage = new TextEmbeddingTokenUsage(3) - }); - - public static readonly - RequestSnapshot, - ModelResponse> BatchNoSse = new( - "batch-text-embedding", - new ModelRequest - { - Input = new BatchGetEmbeddingsInput - { - Url = - "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/text_embedding_file.txt" - }, - Model = "text-embedding-async-v2", - Parameters = new BatchGetEmbeddingsParameters { TextType = "query" } - }, - new ModelResponse - { - RequestId = "db5ce040-4548-9919-9a75-3385ee152335", - Output = new BatchGetEmbeddingsOutput - { - TaskId = "6075262c-b56d-4968-9abf-2a9784a90f3e", - TaskStatus = DashScopeTaskStatus.Pending - } - }); - } - public static class Tokenization { public static readonly @@ -1301,379 +24,6 @@ public static readonly }); } - public static class Tasks - { - public static readonly RequestSnapshot> - Unknown = new( - "get-task-unknown", - new DashScopeTask( - "85c25460-6440-91a7-b14e-2978fe60bd0f", - new BatchGetEmbeddingsOutput { TaskId = "1111", TaskStatus = DashScopeTaskStatus.Unknown })); - - public static readonly RequestSnapshot> - BatchEmbeddingSuccess = new( - "get-task-batch-text-embedding-success", - new DashScopeTask( - "0b2ebeda-a91b-948f-986a-d395cbf1d0e1", - new BatchGetEmbeddingsOutput - { - TaskId = "7408ef3d-a0be-4379-9e72-a6e95a569483", - TaskStatus = DashScopeTaskStatus.Succeeded, - Url = - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/5fc5c860/2024-11-25/c6c4456e-3c66-42ba-a52a-a16c58dda4d6_output_1732514147173.txt.gz?Expires=1732773347&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=perMNS1RdHHroUn2YnXxzTmOZtg%3D", - SubmitTime = new DateTime(2024, 11, 25, 13, 55, 46, 536), - ScheduledTime = new DateTime(2024, 11, 25, 13, 55, 46, 557), - EndTime = new DateTime(2024, 11, 25, 13, 55, 47, 446) - }, - new TextEmbeddingTokenUsage(28))); - - public static readonly RequestSnapshot> - ImageSynthesisRunning = - new( - "get-task-running", - new DashScopeTask( - "edbd4e81-d37b-97f1-9857-d7394829dd0f", - new ImageSynthesisOutput - { - TaskStatus = DashScopeTaskStatus.Running, - TaskId = "9e2b6ef6-285d-4efa-8651-4dbda7d571fa", - SubmitTime = new DateTime(2024, 3, 1, 17, 38, 24, 817), - ScheduledTime = new DateTime(2024, 3, 1, 17, 38, 24, 831), - TaskMetrics = new DashScopeTaskMetrics(4, 0, 0) - })); - - public static readonly RequestSnapshot> - ImageSynthesisSuccess = new( - "get-task-image-synthesis-success", - new DashScopeTask( - "6662e925-4846-9afe-a3af-0d131805d378", - new ImageSynthesisOutput - { - TaskId = "9e2b6ef6-285d-4efa-8651-4dbda7d571fa", - TaskStatus = DashScopeTaskStatus.Succeeded, - SubmitTime = new DateTime(2024, 3, 1, 17, 38, 24, 817), - ScheduledTime = new DateTime(2024, 3, 1, 17, 38, 24, 831), - EndTime = new DateTime(2024, 3, 1, 17, 38, 55, 565), - Results = - [ - new ImageSynthesisResult( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/1d/d4/20240301/8d820c8d/4c48fa53-2907-499b-b9ac-76477fe8d299-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=bEfLmd%2BarXgZyhxcVYOWs%2BovJb8%3D"), - new ImageSynthesisResult( - "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/79/20240301/3ab595ad/aa3e6d8d-884d-4431-b9c2-3684edeb072e-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=fdPScmRkIXyH3TSaSaWwvVjxREQ%3D"), - new ImageSynthesisResult( - "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/0f/20240301/3ab595ad/ecfe06b3-b91c-4950-a932-49ea1619a1f9-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=gNuVAt8iy4X8Nl2l3K4Gu4f0ydw%3D"), - new ImageSynthesisResult( - "https://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/1d/3d/20240301/3ab595ad/3fca748e-d491-458a-bb72-73649af33209-1.png?Expires=1709372333&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=Mx5TueC9I9yfDno9rjzi48opHtM%3D") - ], - TaskMetrics = new DashScopeTaskMetrics(4, 4, 0) - }, - new ImageSynthesisUsage(4))); - - public static readonly RequestSnapshot> - ImageGenerationSuccess = new( - "get-task-image-generation-success", - new DashScopeTask( - "f927c766-5079-90f8-9354-6a87d2167897", - new ImageGenerationOutput - { - TaskId = "c4f94e00-5899-431b-9579-eb1ebe686379", - TaskStatus = DashScopeTaskStatus.Succeeded, - SubmitTime = new DateTime(2024, 3, 2, 22, 22, 13, 026), - ScheduledTime = new DateTime(2024, 3, 2, 22, 22, 13, 051), - EndTime = new DateTime(2024, 3, 2, 22, 22, 21), - StartTime = new DateTime(2024, 3, 2, 22, 22, 13), - StyleIndex = 3, - ErrorCode = 0, - ErrorMessage = "Success", - Results = - [ - new ImageGenerationResult( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/viapi-video/2024-03-02/ac5d435a-9ea9-4287-8666-e1be7bbba943/20240302222213528791_style3_jxdf6o4zwy.jpg?Expires=1709475741&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=LM26fy1Pk8rCfPzihzpUqa3Vst8%3D") - ] - }, - new ImageGenerationUsage(1))); - - public static readonly RequestSnapshot> - BackgroundGenerationSuccess = new( - "get-task-background-generation-success", - new DashScopeTask( - "8b22164d-c784-9a31-bda3-3c26259d4213", - new BackgroundGenerationOutput - { - TaskId = "b2e98d78-c79b-431c-b2d7-c7bcd54465da", - TaskStatus = DashScopeTaskStatus.Succeeded, - SubmitTime = new DateTime(2024, 3, 4, 10, 8, 57, 333), - ScheduledTime = new DateTime(2024, 3, 4, 10, 8, 57, 363), - EndTime = new DateTime(2024, 3, 4, 10, 9, 7, 727), - Results = - [ - new BackgroundGenerationResult( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_0_02dc0bba-8b1d-4648-8b95-eb2b92fe715d.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=OYstgSxWOl%2FOxYTLa2Mx3bi2RWw%3D"), - new BackgroundGenerationResult( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100905_1_e1af86ec-152a-4ebe-b2a0-b40a592043b2.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=p0UXTUdXfp0tFlt0K5tDsA%2Fxl1M%3D") - ], - TaskMetrics = new DashScopeTaskMetrics(2, 2, 0), - TextResults = - new BackgroundGenerationTextResult( - [ - new BackgroundGenerationTextResultUrl( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_0_4645005c-713d-4e92-9629-b12cbe5f3671.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=kmZGXc2s8P4uI%2BVrADITyrPz82U%3D"), - new BackgroundGenerationTextResultUrl( - "https://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/466b5214/20240304/100901_1_b1979b75-c553-4d9b-9c9f-80f401a0d124.png?Expires=1709604547&OSSAccessKeyId=LTAI5tQZd8AEcZX6KZV4G8qL&Signature=cb1Qg%2FkIuZyI7XQqWHjP712N0ak%3D") - ], - [ - new BackgroundGenerationTextResultParams( - 0, - [ - new BackgroundGenerationTextResultLayer( - 0, - "text_mask", - 0, - 0, - 1024, - 257, - Color: "#521b08", - Opacity: 0.8f, - Radius: 0, - Gradient: new BackgroundGenerationTextResultGradient( - "linear", - "pixels", - [ - new BackgroundGenerationTextResultGradientColorStop( - "#521b0800", - 0), - new BackgroundGenerationTextResultGradientColorStop( - "#521b08ff", - 1) - ]) - { - Coords = new Dictionary - { - { "y1", 257 }, - { "x1", 0 }, - { "y2", 0 }, - { "x2", 0 } - } - }), - new BackgroundGenerationTextResultLayer( - 1, - "text", - 25, - 319, - 385, - 77, - SubType: "Title", - FontWeight: "Regular", - FontSize: 67, - Content: "分享好时光", - FontUnderLine: false, - LineHeight: 1f, - FontItalic: false, - FontColor: "#e6baa7", - TextShadow: "1px 0px #80808080", - TextStroke: "1px #fffffff0", - FontFamily: "站酷文艺体", - Alignment: "center", - FontLineThrough: false, - Direction: "horizontal", - Opacity: 1f), - new BackgroundGenerationTextResultLayer( - 2, - "text_mask", - 118, - 395, - 233, - 50, - Color: "#e6baa7", - Opacity: 1f, - Radius: 37, - BoxShadow: "2px 1px #80808080", - Gradient: new BackgroundGenerationTextResultGradient( - "linear", - "pixels", - [ - new BackgroundGenerationTextResultGradientColorStop( - "#e6baa7ff", - 0), - new BackgroundGenerationTextResultGradientColorStop( - "#e6baa7ff", - 1) - ]) - { - Coords = new Dictionary - { - { "y1", 0 }, - { "x1", 0 }, - { "y2", 50 }, - { "x2", 0 } - } - }), - new BackgroundGenerationTextResultLayer( - 3, - "text", - 118, - 395, - 233, - 50, - FontWeight: "Medium", - FontSize: 27, - Content: "只为不一样的你", - FontUnderLine: false, - LineHeight: 1f, - FontItalic: false, - SubType: "SubTitle", - FontColor: "#223629", - TextShadow: null, - FontFamily: "阿里巴巴普惠体", - Alignment: "center", - Opacity: 1f, - FontLineThrough: false, - Direction: "horizontal") - ]), - new BackgroundGenerationTextResultParams( - 1, - [ - new BackgroundGenerationTextResultLayer( - 0, - "text_mask", - 0, - 0, - 1024, - 257, - Color: "#efeae4", - Gradient: new BackgroundGenerationTextResultGradient( - "linear", - "pixels", - [ - new BackgroundGenerationTextResultGradientColorStop( - "#efeae400", - 0), - new BackgroundGenerationTextResultGradientColorStop( - "#efeae4ff", - 1) - ]) - { - Coords = new Dictionary - { - { "y1", 257 }, - { "x1", 0 }, - { "y2", 0 }, - { "x2", 0 } - } - }, - Opacity: 0.8f, - Radius: 0), - new BackgroundGenerationTextResultLayer( - 1, - "text", - 25, - 319, - 385, - 77, - SubType: "Title", - Content: "分享好时光", - FontWeight: "Regular", - FontSize: 67, - FontUnderLine: false, - LineHeight: 1f, - FontItalic: false, - FontColor: "#421f12", - TextStroke: "1px #fffffff0", - TextShadow: "0px 2px #80808080", - FontFamily: "钉钉进步体", - Alignment: "center", - Opacity: 1f, - FontLineThrough: false, - Direction: "horizontal"), - new BackgroundGenerationTextResultLayer( - 2, - "text_mask", - 118, - 395, - 233, - 50, - Color: "#421f12", - Gradient: new BackgroundGenerationTextResultGradient( - "linear", - "pixels", - [ - new BackgroundGenerationTextResultGradientColorStop( - "#421f12ff", - 0), - new BackgroundGenerationTextResultGradientColorStop( - "#421f12ff", - 1) - ]) - { - Coords = new Dictionary - { - { "y1", 0 }, - { "x1", 0 }, - { "y2", 50 }, - { "x2", 0 } - } - }, - Opacity: 1f, - Radius: 37, - BoxShadow: "0px 0px #80808080"), - new BackgroundGenerationTextResultLayer( - 3, - "text", - 118, - 395, - 233, - 50, - FontWeight: "Regular", - FontSize: 27, - Content: "只为不一样的你", - FontUnderLine: false, - LineHeight: 1, - FontItalic: false, - SubType: "SubTitle", - FontColor: "#f1eeec", - TextShadow: null, - FontFamily: "阿里巴巴普惠体", - Alignment: "center", - Opacity: 1, - FontLineThrough: false, - Direction: "horizontal") - ]) - ]) - }, - new BackgroundGenerationUsage(2))); - - public static readonly RequestSnapshot CancelCompletedTask = new( - "cancel-completed-task", - new DashScopeTaskOperationResponse( - "4d496c94-1389-9ca9-a92a-3e732f675686", - "UnsupportedOperation", - "Failed to cancel the task, please confirm if the task is in PENDING status.")); - - public static readonly RequestSnapshot ListTasks = new( - "list-task", - new DashScopeTaskList( - "fcb29ae5-a352-9e7b-901c-e53525376cde", - [ - new DashScopeTaskListItem( - "42677", - "1493478651020171", - "1493478651020171", - 1709260684485, - 1709260684527, - 1709260685184, - "cn-beijing", - "db5ce040-4548-9919-9a75-3385ee152335", - DashScopeTaskStatus.Succeeded, - "6075262c-b56d-4968-9abf-2a9784a90f3e", - "apikey:v1:embeddings:text-embedding:text-embedding:text-embedding-async-v2", - "text-embedding-async-v2") - ], - 1, - 1, - 1, - 10)); - } - public static class ImageSynthesis { public static readonly diff --git a/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs new file mode 100644 index 0000000..a1274f4 --- /dev/null +++ b/test/Cnblogs.DashScope.Sdk.UnitTests/Utils/TestApplicationBizParam.cs @@ -0,0 +1,7 @@ +using System.Text.Json.Serialization; + +namespace Cnblogs.DashScope.Sdk.UnitTests.Utils; + +public record TestApplicationBizParam( + [property: JsonPropertyName("sourceCode")] + string SourceCode);