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


C# DateInterval.AccountForEfficiencies方法代码示例

本文整理汇总了C#中DateInterval.AccountForEfficiencies方法的典型用法代码示例。如果您正苦于以下问题:C# DateInterval.AccountForEfficiencies方法的具体用法?C# DateInterval.AccountForEfficiencies怎么用?C# DateInterval.AccountForEfficiencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateInterval的用法示例。


在下文中一共展示了DateInterval.AccountForEfficiencies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AccountForEfficiencies_FixedEnd_MultipleDateIntervalEfficiencies_ReturnsCorrectAnswer

        public void AccountForEfficiencies_FixedEnd_MultipleDateIntervalEfficiencies_ReturnsCorrectAnswer()
        {
            //         +------------+
            //       |0|  |0|  |0|

            // Result:
            //   +------------------+
            //       |0|  |0|  |0|

            // Arrange
            var now = DateTime.Now;
            var dateInterval = new DateInterval(now, now.AddDays(5));

            var dateIntervalEfficiencies = new List<DateIntervalEfficiency>();
            var efficiency1 = new DateIntervalEfficiency(now.AddDays(1), now.AddDays(2), 0);
            var efficiency2 = new DateIntervalEfficiency(now.AddDays(3), now.AddDays(4), 0);
            var efficiency3 = new DateIntervalEfficiency(now.AddDays(5), now.AddDays(6), 0);

            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Max);

            var correctDateInterval = new DateInterval(dateInterval.Max.Value.Add(-dateInterval.Duration).Add(-efficiency1.Duration).Add(-efficiency2.Duration).Add(-efficiency3.Duration), dateInterval.Max.Value);

            // Assert
            Assert.AreEqual(correctDateInterval, newDateInterval);
        }
开发者ID:asheze,项目名称:Orcomp,代码行数:30,代码来源:AccountForEfficienciesTest.cs

示例2: AccountForEfficiencies_FixedEnd_EmptyListOfDateIntervalEfficiencies_ReturnsUnchangedDateInterval

        public void AccountForEfficiencies_FixedEnd_EmptyListOfDateIntervalEfficiencies_ReturnsUnchangedDateInterval()
        {
            // Arrange
            var now = DateTime.Now;
            var dateInterval = new DateInterval(now, now.AddDays(1));

            var dateIntervalEfficiencies = new List<DateIntervalEfficiency>();

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Max);

            // Assert
            Assert.AreEqual(dateInterval, newDateInterval);
        }
开发者ID:asheze,项目名称:Orcomp,代码行数:14,代码来源:AccountForEfficienciesTest.cs

示例3: AccountForEfficiencies_Overlap1

        public void AccountForEfficiencies_Overlap1()
        {
            // 300% has higher priority than 200%,
            // 50% and 200% have same priority so 50% takes precedence.

            // +--------------------------+            Duration: 60 mins
            // |-----------200%-----------|			   Duration: 50 mins
            // |--50%--|           |-500%-|			   Duration (1): 30 min, (2): 10min

            // Frist we must work out the calendar efficiencies:

            // |--50%--|                               Duration: 30 mins
            //         |---200%---|                    Duration: 20 mins
            //                    |-500%-|             Duration: 10 mins

            // 30 mins at 50%	   => 15   mins at 100%
            // 20 mins at 200%     => 40   mins at 100%
            // 10 mins at 500%     => 50   mins at 100%

            // Result:
            // 60 - 15 - 40 = 5 mins
            // 5 mins at 100% is equivalend to 5/5 = 1 min at 500%
            // Total duration is: 30 + 20 + 1 = 51 mins

            // Arrange
            DateTime end = start.AddMinutes(60);
            var dateInterval = new DateInterval(start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(start, start.AddMinutes(30)), 50);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(30), start.AddMinutes(50)), 200);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(50), start.AddMinutes(60)), 500, 1);
            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(start, start.AddMinutes(51));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:42,代码来源:AccountForEfficienciesOverlapsTest.cs

示例4: AccountForEfficiencies_FixedEnd_NoOverlap_ThreeIntervals4

        public void AccountForEfficiencies_FixedEnd_NoOverlap_ThreeIntervals4()
        {
            // NOTE: This test if with Max end point fixed
            //
            // +----------------------+         Duration: 70 mins
            // |----------|                     Duration: 30 mins at 30%
            //            |-----|               Duration: 15 mins at 200%
            //                  |-|             Duration: 5 mins at 50%

            // The first section is not affected by a calendar period (i.e. 70 - 30 - 15 - 5 = 20)
            // So only 70 - 20 = 50 mins are affected by calendar periods.
            // Details:
            // 30 mins at 30%   => 9 min at 100%
            // 15 mins at 200%  => 30 min at 100%
            // 5 mins at 50%    => 2.5 min at 100%
            // 50 - 9 - 30 - 2.5 = 8.5 mins

            // So the 50 mins affected by the calendar period will last 30 + 15 + 5 + 8.5 = 58.5 mins
            // Total duration 20 + 58.5 = 78.5 mins

            // Arrange
            DateTime end = this.start.AddMinutes(70);

            var dateInterval = new DateInterval(this.start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(this.start, this.start.AddMinutes(30)), 30);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(30), this.start.AddMinutes(45)), 200);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(45), this.start.AddMinutes(50)), 50);
            this.dateIntervalEfficiencies.Add(efficiency1);
            this.dateIntervalEfficiencies.Add(efficiency2);
            this.dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(this.dateIntervalEfficiencies, FixedEndPoint.Max);

            // Assert
            var result = new DateInterval(end.AddMinutes(-78.5), end);
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:Jiannan,项目名称:Orcomp,代码行数:39,代码来源:AccountForEfficienciesNoOverlapTest.cs

示例5: FixedStartPointNoOverlapsWithOffset

        public void FixedStartPointNoOverlapsWithOffset()
        {
            // 1% efficiency
            var dateIntervalEfficiencies = DateIntervalCollectionGenerator.NoOverlaps(now, TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1), numberOfIntervals).Select(x => new DateIntervalEfficiency(x, 1)).ToList();

            var initialInterval = new DateInterval(now, dateIntervalEfficiencies.Last().Max.Value);

            var stopwatch = Stopwatch.StartNew();
            var effectualInterval = initialInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Min);
            stopwatch.Stop();

            Debug.WriteLine(string.Format("Span whole collection, Elapsed time: {0} ms, result is: {1}", stopwatch.ElapsedMilliseconds, effectualInterval));

            initialInterval = new DateInterval(now, dateIntervalEfficiencies[numberOfIntervals / 2].Max.Value);

            stopwatch.Reset();
            stopwatch.Start();
            effectualInterval = initialInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Min);
            stopwatch.Stop();

            Debug.WriteLine(string.Format("Span half collection, Elapsed time: {0} ms, result is: {1}", stopwatch.ElapsedMilliseconds, effectualInterval));
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:22,代码来源:AccountForEfficienciesBenchmark.cs

示例6: AccountForEfficiencies_NoOverlap_OneInterval

        public void AccountForEfficiencies_NoOverlap_OneInterval()
        {
            // +--------------------------------+      Duration: 60 mins
            // |--------|                              Duration: 30 mins at 20%
            //
            // Result
            // |----------------|                      Duration: 84 mins

            // Arrange
            DateTime end = this.start.AddMinutes(60);

            var dateInterval = new DateInterval(this.start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(this.start, this.start.AddMinutes(30)), 20); // 30 mins at 20%
            this.dateIntervalEfficiencies.Add(efficiency1);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(this.dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(this.start, this.start.AddMinutes(84));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:Jiannan,项目名称:Orcomp,代码行数:23,代码来源:AccountForEfficienciesNoOverlapTest.cs

示例7: AccountForEfficiencies_NoOverlap_TwoIntervals2

        public void AccountForEfficiencies_NoOverlap_TwoIntervals2()
        {
            // +------------------+     Duration: 60 mins
            //           |--------|     Duration: 20 mins at 40%
            //     |-----|              Duration: 10 mins at 150%
            //
            // Result
            // 20 mins at 40%  => 8 mins at 100%
            // 10 mins at 150% => 15 mins at 100%
            // 60 - 8 - 15 = 37
            //
            // Total = 20 + 10 + 37 = 67 mins

            // Arrange
            DateTime end = this.start.AddMinutes(60);

            var dateInterval = new DateInterval(this.start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(40), this.start.AddMinutes(60)), 40);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(30), this.start.AddMinutes(40)), 150);
            this.dateIntervalEfficiencies.Add(efficiency1);
            this.dateIntervalEfficiencies.Add(efficiency2);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(this.dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(this.start, this.start.AddMinutes(67));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:Jiannan,项目名称:Orcomp,代码行数:30,代码来源:AccountForEfficienciesNoOverlapTest.cs

示例8: FixedStartPointWithOverlapsWithSpan

        public void FixedStartPointWithOverlapsWithSpan()
        {
            // |-------------------|  100% with highest priority
            // |-------------------|  90
            //   |---------------|    80
            //      |---------|       70
            //        |-----|         60

            // 1% efficiency
            var dateIntervalEfficiencies = DateIntervalCollectionGenerator.OverlapsWithDecreasingDuration(now, TimeSpan.FromMinutes(1), numberOfIntervals).Select((x, i) => new DateIntervalEfficiency(x, numberOfIntervals - i)).ToList();

            var initialInterval = new DateInterval(now, dateIntervalEfficiencies.First().Max.Value);

            dateIntervalEfficiencies.Add(new DateIntervalEfficiency(initialInterval, 100, 1));

            var stopwatch = Stopwatch.StartNew();
            var effectualInterval = initialInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Min);
            stopwatch.Stop();

            Debug.WriteLine(string.Format("Span whole collection, Elapsed time: {0} ms, result is: {1}", stopwatch.ElapsedMilliseconds, effectualInterval));
            Assert.AreEqual(initialInterval, effectualInterval);

            initialInterval = new DateInterval(now, dateIntervalEfficiencies[numberOfIntervals / 2].Max.Value);

            stopwatch.Reset();
            stopwatch.Start();
            effectualInterval = initialInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Min);
            stopwatch.Stop();

            Debug.WriteLine(string.Format("Span half collection, Elapsed time: {0} ms, result is: {1}", stopwatch.ElapsedMilliseconds, effectualInterval));
            Assert.AreEqual(initialInterval, effectualInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:32,代码来源:AccountForEfficienciesBenchmark.cs

示例9: AccountForEfficiencies_OneZeroEfficiencyCalendarStartWhenDateIntervalEnds_ReturnsSameDateInterval

        public void AccountForEfficiencies_OneZeroEfficiencyCalendarStartWhenDateIntervalEnds_ReturnsSameDateInterval()
        {
            // +-----------+
            //             |-----0-----|

            // Result:
            // +-----------+
            //             |-----0-----|

            // Arrange
            var now = DateTime.Now;
            var dateInterval = new DateInterval(now, now.AddDays(1));

            var dateIntervalEfficiencies = new List<DateIntervalEfficiency>();
            dateIntervalEfficiencies.Add(new DateIntervalEfficiency(now.AddDays(1), now.AddDays(3), 0));

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            var correctDateInterval = dateInterval;

            // Assert
            Assert.AreEqual(correctDateInterval, newDateInterval);
        }
开发者ID:asheze,项目名称:Orcomp,代码行数:24,代码来源:AccountForEfficienciesTest.cs

示例10: DateInterval

        public void AccountForEfficiencies_FixedEnd_OneZeroEfficiencyCalendarStartsInAndEndsAfterDateInterval_ReturnsCorrectResult()
        {
            //      +-----------+
            //               |--0--|

            // Result:
            //  +---------------+
            //               |--0--|

            // Arrange
            var now = DateTime.Now;
            var dateInterval = new DateInterval(now, now.AddDays(4));

            var dateIntervalEfficiencies = new List<DateIntervalEfficiency>();
            var efficiency1 = new DateIntervalEfficiency(now.AddDays(3), now.AddDays(5), 0);
            dateIntervalEfficiencies.Add(efficiency1);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies, FixedEndPoint.Max);

            var correctDateInterval = new DateInterval(dateInterval.Min.Value.Add( - (dateInterval.Max.Value - efficiency1.Min.Value) ), dateInterval.Max.Value);

            // Assert
            Assert.AreEqual(correctDateInterval, newDateInterval);
        }
开发者ID:asheze,项目名称:Orcomp,代码行数:25,代码来源:AccountForEfficienciesTest.cs

示例11: AccountForEfficiencies_Overlap6

        public void AccountForEfficiencies_Overlap6()
        {
            // +--------------------------+           Duration: 100 mins
            //   |------120%---------|				  Duration: 45 mins, starts at 10
            //     |----100%-------|                  Duration: 35 mins, starts at 15
            //         |-30%-|			      		  Duration: 25 mins, starts at 20

            // Work out the calendar efficiences:

            // Assumption all the calendar periods have the same efficiency. To the lowest efficiency takes precedence

            //|--|									  Duration: 10 mins
            //    |-|                                 Duration: 5 mins at 120%
            //      |-|                               Duration: 5 mins at 100%
            //        |-----|                         Duration: 25 mins at 30%
            //              |-|                       Duration: 5 mins at 100%
            //                |-|                     Duration: 5 mins at 120%
            //                  |-----|               Duration: 45 mins at 100% (which is the default value)

            // 10 mins at 100%	  => 10   mins at 100%
            // 5 mins at 120%	  => 6    mins at 100%
            // 5 mins at 100%     => 5    mins at 100%
            // 25 mins at 30%	  => 7.5  mins at 100%
            // 5 mins at 100%	  => 5    mins at 100%
            // 5 mins at 120%	  => 6    mins at 100%
            // 45 mins at 100%    => 45   mins at 100%

            // Result:
            // 100 - 10 - 6 - 5 - 7.5 - 5 - 6 - 45 = 15.5 mins
            // Total duration is: 10 + 5 + 5 + 25 + 5 + 5 + 45 + 15.5 = 115.5 mins

            // Arrange
            DateTime end = start.AddMinutes(100);

            var dateInterval = new DateInterval(start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(10), start.AddMinutes(55)), 120);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(15), start.AddMinutes(50)), 100);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(20), start.AddMinutes(45)), 30);
            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(start, start.AddMinutes(115.5));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:50,代码来源:AccountForEfficienciesOverlapsTest.cs

示例12: AccountForEfficiencies_Overlap5

        public void AccountForEfficiencies_Overlap5()
        {
            //+--------------------------+            Duration: 100 mins
            //   |------120%---------|				  Duration: 45 mins, starts at 10 (PRIORITY)
            //     |----100%-------|                  Duration: 35 mins, starts at 15
            //         |-30%-|			      		  Duration: 25 mins, starts at 20

            // Work out the calendar efficiences:
            // If 120% is the priority then it takes precedence over the 100% and the 30% calendar period
            // Because 100% and 30% have the same priority, 30% takes precedence (lower efficiency)

            // |--|									Duration: 10 mins
            //    |---120%-----------|              Duration: 45 mins
            //                       |-100%-|		Duration: 45 mins

            // 10 mins at 100%	  => 10   mins at 100%
            // 45 mins at 120%	  => 54   mins at 100%
            // 45 mins at 100%    => 45   mins at 100%

            // Result:

            // 100 - 10 - 54 = 36 mins
            // Total duration is: 10 + 45 + 36 = 91

            // Arrange
            DateTime end = start.AddMinutes(100);

            var dateInterval = new DateInterval(start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(10), start.AddMinutes(55)), 120, 1);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(15), start.AddMinutes(50)), 100);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(20), start.AddMinutes(45)), 30);
            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(start, start.AddMinutes(91));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:43,代码来源:AccountForEfficienciesOverlapsTest.cs

示例13: AccountForEfficiencies_Overlap4

        public void AccountForEfficiencies_Overlap4()
        {
            // +---------------------------------+       Duration: 90 mins
            //   |------90%----------|			   	     Duration: 40 mins, starts at 10
            //   |--30%--|                               Duration: 15 mins starts at 10
            //                          |-150%-|	     Duration: 10 mins finishes at 80 mins

            // Work out the calendar efficiences

            // |--|										   Duration: 10 mins at 100%
            //     |--30%--|                               Duration: 15 mins
            //             |-----90%----|                  Duration: 25 mins
            //                          |---|              Duration: 20 mins at 100%
            //                               |-150%-|      Duration: 10 mins
            //                                      |--|   Duration: 10 mins at 100%

            // 10 mins at 10%	   => 10   mins at 100%
            // 15 mins at 30%	   => 4.5  mins at 100%
            // 25 mins at 90%      => 22.5   mins at 100%
            // 20 mins at 100%	   => 20   mins at 100%
            // 10 mins at 150%     => 15   mins at 100%
            // 10 mins at 100%	   => 10   mins at 100%

            // Result:
            // 90 - 10 - 4.5 - 22.5 - 20 - 15 - 10 = 8 mins
            // Total duration is: 10 + 15 + 25 + 20 + 10 + 10 + 8 = 98 mins

            // Arrange
            DateTime end = start.AddMinutes(90);

            var dateInterval = new DateInterval(start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(10), start.AddMinutes(50)), 90);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(10), start.AddMinutes(25)), 30, 1);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(70), start.AddMinutes(80)), 150);
            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);
            dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(start, start.AddMinutes(98));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:46,代码来源:AccountForEfficienciesOverlapsTest.cs

示例14: AccountForEfficiencies_Overlap3

        public void AccountForEfficiencies_Overlap3()
        {
            // +--------------------------+                Duration: 55 mins
            //    |------80%-------|			  	       Duration: 30 mins, starts at 15
            //                  |-200%-|	               Duration: 20 mins starts at 40

            //Work out the calendar efficiences
            // |--|                                         Duration: 15 mins at 100%
            //    |----80%-----|                            Duration: 30 mins
            //                 |--200%-|                    Duration: 15 mins

            // 15 mins at 100%     => 15 mins at 100%
            // 30 mins at 80%	   => 24 mins at 100%
            // 15 mins at 200%     => 30 mins at 100%

            // Result:

            // 55 - 15 - 24 = 16 mins
            // 16 min at 100% is equivalend to 8 mins at 200%
            // Total duration is: 15 + 30 + 8 = 53 min

            // Arrange
            DateTime end = start.AddMinutes(55);

            var dateInterval = new DateInterval(start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(15), start.AddMinutes(45)), 80, 1);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(start.AddMinutes(40), start.AddMinutes(60)), 200);
            dateIntervalEfficiencies.Add(efficiency1);
            dateIntervalEfficiencies.Add(efficiency2);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(start, start.AddMinutes(53));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:sidlovskyy,项目名称:Orcomp,代码行数:38,代码来源:AccountForEfficienciesOverlapsTest.cs

示例15: AccountForEfficiencies_NoOverlap_ThreeIntervals

        public void AccountForEfficiencies_NoOverlap_ThreeIntervals()
        {
            // +------------------+                         Duration: 70 mins
            // |------------------|                         Duration: 60 mins at 10%
            //                    |---------|               Duration: 40 mins at 80%
            //                              |---------|     Duration: 80 mins at 200%
            //
            // Result
            // 60 mins at 10%  => 6 mins at 100%
            // 40 mins at 80%  => 32 mins at 100%
            // 80 mins at 200% => 160 mins at 100%
            //
            // 70 - 6 - 32 = 32 mins
            // 32 mins at 100% => 16 mins at 200%
            //
            // Total = 60 + 40 + 16 = 116 mins

            // Arrange
            DateTime end = this.start.AddMinutes(70);

            var dateInterval = new DateInterval(this.start, end);

            var efficiency1 = new DateIntervalEfficiency(new DateInterval(this.start, this.start.AddMinutes(60)), 10);
            var efficiency2 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(60), this.start.AddMinutes(100)), 80);
            var efficiency3 = new DateIntervalEfficiency(new DateInterval(this.start.AddMinutes(100), this.start.AddMinutes(180)), 200);
            this.dateIntervalEfficiencies.Add(efficiency1);
            this.dateIntervalEfficiencies.Add(efficiency2);
            this.dateIntervalEfficiencies.Add(efficiency3);

            // Act
            var newDateInterval = dateInterval.AccountForEfficiencies(this.dateIntervalEfficiencies);

            // Assert
            var result = new DateInterval(this.start, this.start.AddMinutes(116));
            Assert.AreEqual(result, newDateInterval);
        }
开发者ID:Jiannan,项目名称:Orcomp,代码行数:36,代码来源:AccountForEfficienciesNoOverlapTest.cs


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