コード例 #1
0
        /// <summary>
        /// Wandelt diese Ausnahmebeschreibung in ein entsprechendes Äauivalent für die Planung.
        /// </summary>
        /// <param name="duration">Die Dauer der zugehörigen Aufzeichnung.</param>
        /// <returns>Die gewünschte äquivalente Repräsentation der Ausnahmeregel.</returns>
        public PlanException ToPlanException( TimeSpan duration )
        {
            // Create new
            var exception = new PlanException { ExceptionDate = When.Date };

            // Set data
            if (Duration.HasValue)
                exception.DurationDelta = TimeSpan.FromMinutes( Duration.Value ) - duration;
            if (ShiftTime.HasValue)
                exception.StartDelta = TimeSpan.FromMinutes( ShiftTime.Value );

            // Report
            return exception;
        }
コード例 #2
0
ファイル: PlanSpecs.cs プロジェクト: davinx/DVB.NET---VCR.NET
        public void There_Can_Be_Only_One_Exception_Per_Date()
        {
            // Create bad exception
            var exception1 = new PlanException { ExceptionDate = DateTime.Now.Date };
            var exception2 = new PlanException { ExceptionDate = exception1.ExceptionDate };

            // Create component under test
            var componentUnderTest = new RecordingScheduler( StringComparer.InvariantCultureIgnoreCase );

            // Add
            componentUnderTest.Add( ResourceMock.Create( "r1", SourceMock.Create( "s1" ) ) );
            componentUnderTest.Add( RecordingDefinition.Create( false, "test", Guid.NewGuid(), null, SourceMock.Create( "s1" ), DateTime.UtcNow, TimeSpan.FromMinutes( 12 ) ), exception1, exception2 );
        }
コード例 #3
0
        public void A_Repeating_Recording_Can_Have_Exceptions()
        {
            // Create recordings
            var repeatStart = TimeBias.AddHours( 1 );
            var repeatStartLocal = repeatStart.ToLocalTime();
            var plan =
                RecordingDefinition.Create
                    (
                        false,
                        "test",
                        Guid.NewGuid(),
                        null,
                        SourceMock.Source1Group1Free,
                        repeatStart,
                        TimeSpan.FromMinutes( 90 ),
                        DateTime.MaxValue.Date,
                        Enum.GetValues( typeof( DayOfWeek ) ).Cast<DayOfWeek>().ToArray()
                    );
            var exception1 =
                new PlanException
                {
                    ExceptionDate = repeatStartLocal.AddDays( 12 ).Date,
                    DurationDelta = TimeSpan.FromMinutes( -10 ),
                    StartDelta = TimeSpan.FromMinutes( 10 ),
                };
            var exception2 =
                new PlanException
                {
                    ExceptionDate = repeatStartLocal.AddDays( 22 ).Date,
                    DurationDelta = TimeSpan.FromMinutes( 10 ),
                };
            var exception3 =
                new PlanException
                {
                    ExceptionDate = repeatStartLocal.AddDays( 24 ).Date,
                    DurationDelta = TimeSpan.FromMinutes( -100 ),
                };

            // Create component under test
            var cut =
                new RecordingScheduler( StringComparer.InvariantCultureIgnoreCase )
                    {
                        { FreeTVDevice },
                        { plan, exception1, exception2, exception3 },
                    };

            // Load 
            var schedules = cut.GetSchedules( TimeBias ).Take( 30 ).ToArray();

            // Check
            for (int i = 30; i-- > 0;)
                if (i == 12)
                {
                    // Validate
                    Assert.AreEqual( schedules[i].Time.Start, repeatStart.AddDays( i ).AddMinutes( 10 ), "Start {0}", i );
                    Assert.AreEqual( schedules[i].Time.Duration, TimeSpan.FromMinutes( 80 ), "Duration {0}", i );
                }
                else if (i == 22)
                {
                    // Validate
                    Assert.AreEqual( schedules[i].Time.Start, repeatStart.AddDays( i ), "Start {0}", i );
                    Assert.AreEqual( schedules[i].Time.Duration, TimeSpan.FromMinutes( 100 ), "Duration {0}", i );
                }
                else
                {
                    // Correct
                    var day = (i < 24) ? i : i + 1;

                    // Validate
                    Assert.AreEqual( schedules[i].Time.Start, repeatStart.AddDays( day ), "Start {0}", i );
                    Assert.AreEqual( schedules[i].Time.Duration, TimeSpan.FromMinutes( 90 ), "Duration {0}", i );
                }
        }
コード例 #4
0
ファイル: PlanSpecs.cs プロジェクト: davinx/DVB.NET---VCR.NET
        public void Exceptions_Must_Be_Defined_On_A_Full_Date()
        {
            // Create bad exception
            var exception = new PlanException { ExceptionDate = DateTime.Now.Date.AddMinutes( 12 ) };

            // Create component under test
            var componentUnderTest = new RecordingScheduler( StringComparer.InvariantCultureIgnoreCase );

            // Add
            componentUnderTest.Add( ResourceMock.Create( "r1", SourceMock.Create( "s1" ) ) );
            componentUnderTest.Add( RecordingDefinition.Create( false, "test", Guid.NewGuid(), null, SourceMock.Create( "s1" ), DateTime.UtcNow, TimeSpan.FromMinutes( 12 ) ), exception );
        }