本文整理汇总了C#中Collection.Collapse方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.Collapse方法的具体用法?C# Collection.Collapse怎么用?C# Collection.Collapse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.Collapse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collapse_NoTasksInCollectionWhenExecuted_ReturnsEmptyList
public void Collapse_NoTasksInCollectionWhenExecuted_ReturnsEmptyList()
{
// Arrange
var taskCollection = new Collection<ITask>();
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
Assert.False(tasks.Any());
}
示例2: Collapse_TaskCollection2_ReturnsCorrectEnumerable
public void Collapse_TaskCollection2_ReturnsCorrectEnumerable()
{
// Arrange
var taskCollection = new Collection<ITask>();
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1);
DateTime t3 = t1.AddHours(2);
DateTime t4 = t1.AddHours(3);
DateTime t5 = t1.AddHours(4);
DateTime t6 = t1.AddHours(5);
DateTime t7 = t1.AddHours(6);
DateTime t8 = t1.AddHours(7);
DateTime t9 = t1.AddHours(8);
// 1----2----3----4----5----6----7----8----9
taskCollection.Add(Task.CreateUsingQuantityPerHour(t1, t6, 100F)); // +------------------------+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t8, t9, -200F)); // +----+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t3, t5, 200F)); // +---------+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t6, t7, 200F)); // +----+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t4, 200F)); // +---------+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t3, -300F)); // +----+
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
var tasksCorrect = new Collection<ITask>();
// 1----2----3----4----5----6----7----8----9
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t1, t2, 100F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t2, t3, 0F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t3, t4, 500F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t4, t5, 300F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t5, t6, 100F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t6, t7, 200F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t8, t9, -200F)); // +----+
Assert.AreEqual(tasksCorrect, tasks);
}
示例3: Collapse_TaskCollection_ReturnsCorrectEnumerable
public void Collapse_TaskCollection_ReturnsCorrectEnumerable()
{
// Arrange
var taskCollection = new Collection<ITask>();
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1);
DateTime t3 = t1.AddHours(2);
DateTime t4 = t1.AddHours(3);
// 1----2----3----4
taskCollection.Add(Task.CreateUsingQuantityPerHour(t1, t3, 100F)); // +---------+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t4, 200F)); // +---------+
taskCollection.Add(Task.CreateUsingQuantityPerHour(t2, t3, -300F)); // +----+
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
var tasksCorrect = new Collection<ITask>();
// 1----2----3----4
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t1, t2, 100F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t2, t3, 0F)); // +----+
tasksCorrect.Add(Task.CreateUsingQuantityPerHour(t3, t4, 200F)); // +----+
Assert.AreEqual(tasksCorrect, tasks);
}
示例4: Collapse_TwoTasksWithSameDateRange_ReturnsOneItem
public void Collapse_TwoTasksWithSameDateRange_ReturnsOneItem()
{
// Arrange
var taskCollection = new Collection<ITask>();
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1.5);
taskCollection.Add(Task.CreateUsingQuantity(t1, t2, 100F));
taskCollection.Add(Task.CreateUsingQuantity(t1, t2, 200F));
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
Assert.True(tasks.Count() == 1);
}
示例5: Collapse_TwoTasksWithoutOverlappingDateRange_ReturnsTwoItems
public void Collapse_TwoTasksWithoutOverlappingDateRange_ReturnsTwoItems()
{
// Arrange
var taskCollection = new Collection<ITask>();
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1.5);
DateTime t3 = t1.AddHours(2);
DateTime t4 = t1.AddHours(3);
taskCollection.Add(Task.CreateUsingQuantity(t1, t2, 100F));
taskCollection.Add(Task.CreateUsingQuantity(t3, t4, 200F));
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
Assert.True(tasks.Count() == 2);
}
示例6: Collapse_ThreeTasksWithEndTimeOfOneEqualToStartTimeOfOther_ReturnsThreeItem
public void Collapse_ThreeTasksWithEndTimeOfOneEqualToStartTimeOfOther_ReturnsThreeItem()
{
// Arrange
var taskCollection = new Collection<ITask>();
DateTime t1 = DateTime.Now;
DateTime t2 = t1.AddHours(1);
DateTime t3 = t1.AddHours(2);
DateTime t4 = t1.AddHours(3);
taskCollection.Add(Task.CreateUsingQuantity(t1, t2, 100F)); // +----+
taskCollection.Add(Task.CreateUsingQuantity(t2, t3, -100F));// +----+
taskCollection.Add(Task.CreateUsingQuantity(t3, t4, 100F)); // +----+
// Act
IEnumerable<ITask> tasks = taskCollection.Collapse();
// Assert
Assert.True(tasks.Count() == 3);
}