当前位置: 首页>>代码示例>>C#>>正文


C# Collection.Collapse方法代码示例

本文整理汇总了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());
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:11,代码来源:TaskCollectionExtensionTest.cs

示例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);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:37,代码来源:TaskCollectionExtensionTest.cs

示例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);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:25,代码来源:TaskCollectionExtensionTest.cs

示例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);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:15,代码来源:TaskCollectionExtensionTest.cs

示例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);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:17,代码来源:TaskCollectionExtensionTest.cs

示例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);
        }
开发者ID:Orcomp,项目名称:Orcomp,代码行数:18,代码来源:TaskCollectionExtensionTest.cs


注:本文中的Collection.Collapse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。