我正在使用SpecExplorer生成一个测试套件。我有一个函数应该返回一个排序的字符串集合(与List.Sort()相同的排序行为)。
在模型中,我使用的是Microsoft.Modeling.Sequence。不可能使用列表,因为如果使用列表,SpecExplorer无法计算当前状态.
我的问题是:如何在不使用列表的情况下返回排序的Microsoft.Modeling.Sequence .我知道我可以比较所有的字符串彼此,并与每一个比较步骤创建一个新的不变序列,但这似乎太复杂了。有更简单的解决办法吗?
OffTopic:没有SpecExplorer标签.
编辑:
当前的工作示例
Sequence<string> toSort = new Sequence<string>(new string[] { "Delta", "delta", "Alpha", "Gamma", "Beta" });
Sequence<string> sorted = new Sequence<string>();
while (toSort.Count != 0)
{
int currentMaxIndex = -1;
for (int i = 0; i < toSort.Count; i++)
if (currentMaxIndex == -1 || toSort[i].CompareTo(toSort[currentMaxIndex]) < 0)
currentMaxIndex = i;
sorted = sorted.Add(toSort[currentMaxIndex]);
toSort = toSort.RemoveAt(currentMaxIndex);
}发布于 2014-07-01 18:12:34
也许有些问题:
https://stackoverflow.com/questions/24258565
复制相似问题