本文整理汇总了C#中ItemCollection.SequenceEqual方法的典型用法代码示例。如果您正苦于以下问题:C# ItemCollection.SequenceEqual方法的具体用法?C# ItemCollection.SequenceEqual怎么用?C# ItemCollection.SequenceEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemCollection
的用法示例。
在下文中一共展示了ItemCollection.SequenceEqual方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_sorting_update_item_changes_order
public void Test_sorting_update_item_changes_order()
{
var item1 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Canceled });
var item2 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 2, Status = WorkItemStatusEnum.Complete });
var item3 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 3, Status = WorkItemStatusEnum.Failed });
var item4 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Idle });
var item5 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 5, Status = WorkItemStatusEnum.Pending });
var items = new ItemCollection<ActivityMonitorComponent.WorkItem>();
var manager = new ActivityMonitorComponent.WorkItemUpdateManager(items, NoFilter, () => { });
// insert items in sorted order, and verify that this order is preserved
manager.Update(new[] { item1, item2, item3, item4, item5 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// item 1 changes to Complete - should not cause a change in list order
item1 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Canceling });
manager.Update(new[] { item1 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// item 4 changes to Complete, causing it to be repositioned in the list
item4 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Complete });
manager.Update(new[] { item4 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item4, item3, item5 }) || items.SequenceEqual(new[] { item1, item4, item2, item3, item5 }));
}
示例2: Test_sorting_update_nonsort_property_retains_order
public void Test_sorting_update_nonsort_property_retains_order()
{
var item1 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item2 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 2, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item3 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 3, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item4 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var item5 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 5, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Normal });
var items = new ItemCollection<ActivityMonitorComponent.WorkItem>();
items.AddRange(new[] { item1, item2, item3, item4, item5 });
// the idea here is that if an item is updated, but the sorty property (Status) has not changed,
// then the item does not move around in the list, but is updated in place
var manager = new ActivityMonitorComponent.WorkItemUpdateManager(items, NoFilter, () => { });
// item 1 Priority changes - should not cause a change in list order
var x = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.Stat});
manager.Update(new[] { x }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// item 4 Priority changes - should not cause a change in list order
var y = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Pending, Priority = WorkItemPriorityEnum.High});
manager.Update(new[] { y }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
}
示例3: Test_sorting_items_inserted_in_sorted_order
public void Test_sorting_items_inserted_in_sorted_order()
{
var item1 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 1, Status = WorkItemStatusEnum.Canceled });
var item2 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 2, Status = WorkItemStatusEnum.Complete });
var item3 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 3, Status = WorkItemStatusEnum.Failed });
var item4 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 4, Status = WorkItemStatusEnum.Idle });
var item5 = new ActivityMonitorComponent.WorkItem(new WorkItemData { Identifier = 5, Status = WorkItemStatusEnum.Pending });
var items = new ItemCollection<ActivityMonitorComponent.WorkItem>();
var manager = new ActivityMonitorComponent.WorkItemUpdateManager(items, NoFilter, () => { });
// insert items in sorted order, and verify that this order is preserved
manager.Update(new [] { item1, item2, item3, item4, item5 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// insert items in reverse order, and verify that they still end up in sorted order
items.Clear();
manager.Update(new[] { item5, item4, item3, item2, item1 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
// insert items out of sorted order, and verify that they still end up in sorted order
items.Clear();
manager.Update(new[] { item3, item5, item4, item1, item2 }, StatusComparison);
Assert.IsTrue(items.SequenceEqual(new[] { item1, item2, item3, item4, item5 }));
}