diff --git a/GFramework.Core.Tests/Coroutine/ComplexQuery.cs b/GFramework.Core.Tests/Coroutine/ComplexQuery.cs new file mode 100644 index 00000000..bb58ec3f --- /dev/null +++ b/GFramework.Core.Tests/Coroutine/ComplexQuery.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using GFramework.Core.Abstractions.Architectures; +using GFramework.Core.Abstractions.Query; + +namespace GFramework.Core.Tests.Coroutine; + +/// +/// 为 提供复杂对象结果的查询测试替身。 +/// +internal class ComplexQuery : IQuery +{ + private IArchitectureContext? _context; + + /// + /// 获取或设置测试查询使用的名称。 + /// + public string Name { get; set; } = string.Empty; + + /// + /// 获取或设置需要聚合的整数集合。 + /// + public List Values { get; set; } = new(); + + /// + /// 获取或设置附加元数据。 + /// + public Dictionary Metadata { get; set; } = new(StringComparer.Ordinal); + + /// + /// 绑定当前查询所属的架构上下文。 + /// + /// 测试期间由查询管线注入的上下文。 + public void SetContext(IArchitectureContext context) + { + _context = context; + } + + /// + /// 获取当前查询持有的架构上下文。 + /// + /// 此前通过 绑定的上下文实例。 + public IArchitectureContext GetContext() + { + return _context!; + } + + /// + /// 执行查询并生成复杂结果对象。 + /// + /// 包含名称、求和值和计数信息的测试结果。 + public ComplexResult Do() + { + return new ComplexResult + { + ProcessedName = Name, + Sum = Values.Sum(), + Count = Values.Count + }; + } +} diff --git a/GFramework.Core.Tests/Coroutine/ComplexResult.cs b/GFramework.Core.Tests/Coroutine/ComplexResult.cs new file mode 100644 index 00000000..c6501114 --- /dev/null +++ b/GFramework.Core.Tests/Coroutine/ComplexResult.cs @@ -0,0 +1,22 @@ +namespace GFramework.Core.Tests.Coroutine; + +/// +/// 为 提供复杂对象结果的测试载体。 +/// +internal class ComplexResult +{ + /// + /// 获取或设置处理后的名称。 + /// + public string ProcessedName { get; set; } = string.Empty; + + /// + /// 获取或设置整数集合的求和结果。 + /// + public int Sum { get; set; } + + /// + /// 获取或设置整数集合中的元素数量。 + /// + public int Count { get; set; } +} diff --git a/GFramework.Core.Tests/Coroutine/IntQuery.cs b/GFramework.Core.Tests/Coroutine/IntQuery.cs new file mode 100644 index 00000000..02b8826e --- /dev/null +++ b/GFramework.Core.Tests/Coroutine/IntQuery.cs @@ -0,0 +1,44 @@ +using GFramework.Core.Abstractions.Architectures; +using GFramework.Core.Abstractions.Query; + +namespace GFramework.Core.Tests.Coroutine; + +/// +/// 为 提供布尔结果的整数查询测试替身。 +/// +internal class IntQuery : IQuery +{ + private IArchitectureContext? _context; + + /// + /// 获取或设置参与查询计算的整数值。 + /// + public int Value { get; set; } + + /// + /// 绑定当前查询所属的架构上下文。 + /// + /// 测试期间由查询管线注入的上下文。 + public void SetContext(IArchitectureContext context) + { + _context = context; + } + + /// + /// 获取当前查询持有的架构上下文。 + /// + /// 此前通过 绑定的上下文实例。 + public IArchitectureContext GetContext() + { + return _context!; + } + + /// + /// 执行查询并返回布尔结果。 + /// + /// 大于零时返回 + public bool Do() + { + return Value > 0; + } +} diff --git a/GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs b/GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs index 78b97394..e608b660 100644 --- a/GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs +++ b/GFramework.Core.Tests/Coroutine/QueryCoroutineExtensionsTests.cs @@ -329,63 +329,3 @@ public class QueryCoroutineExtensionsTests Assert.That(receivedResult, Is.Null); } } - -/// -/// 用于测试的整数查询类 -/// -internal class IntQuery : IQuery -{ - private IArchitectureContext? _context; - public int Value { get; set; } - - public void SetContext(IArchitectureContext context) - { - _context = context; - } - - public IArchitectureContext GetContext() - { - return _context!; - } - - public bool Do() - { - return Value > 0; - } -} - -/// -/// 用于测试的复杂查询类 -/// -internal class ComplexQuery : IQuery -{ - private IArchitectureContext? _context; - public string Name { get; set; } = string.Empty; - public List Values { get; set; } = new(); - public Dictionary Metadata { get; set; } = new(StringComparer.Ordinal); - - public void SetContext(IArchitectureContext context) - { - _context = context; - } - - public IArchitectureContext GetContext() - { - return _context!; - } - - public ComplexResult Do() - { - return new ComplexResult { ProcessedName = Name, Sum = Values.Sum(), Count = Values.Count }; - } -} - -/// -/// 用于测试的复杂结果类 -/// -internal class ComplexResult -{ - public string ProcessedName { get; set; } = string.Empty; - public int Sum { get; set; } - public int Count { get; set; } -}