Example #1
0
        public void CanCreateUpdateDeleteSchedule()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var scheduleName = TestUtilities.GenerateName("hourlySche");
                    var startTime    = DateTimeOffset.Now.AddDays(1);
                    var expiryTime   = startTime.AddDays(5);

                    var schedule = testFixture.CreateHourlySchedule(scheduleName, startTime, expiryTime);
                    Assert.NotNull(schedule);

                    schedule = testFixture.GetSchedule(schedule.Name);
                    Assert.NotNull(schedule);

                    Assert.Equal(1, (int)(long)schedule.Interval);
                    Assert.Equal(ScheduleFrequency.Hour, schedule.Frequency);

                    schedule.IsEnabled   = false;
                    schedule.Description = "hourly schedule";
                    testFixture.UpdateSchedule(schedule);
                    var updatedSchedule = testFixture.GetSchedule(schedule.Name);
                    Assert.False(updatedSchedule.IsEnabled);
                    Assert.Equal(schedule.Description, updatedSchedule.Description);

                    testFixture.DeleteSchedule(schedule.Name);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        schedule = testFixture.GetSchedule(schedule.Name);
                    });
                }
            }
        }