コード例 #1
0
        public async Task CreateScheduleTest()
        {
            var commandState = HueRequestBuilder.Modify.Light(7).TurnOn().Build();
            var newSchedule  = new GetScheduleResponse
            {
                AutoDelete  = true,
                Name        = "new Timer",
                Description = "testing that scheduling",
                Timing      = ScheduleTiming.CreateNew(ScheduleTimingTypes.Alarm),
                Command     = new Command(commandState),
                Status      = ScheduleStatus.Enabled
            };

            newSchedule.Timing.BaseDate = DateTime.Now.AddDays(1);

            IHueRequest request = new CreateScheduleRequest {
                NewSchedule = newSchedule
            };

            var response = await _client.GetResponseAsync(request);

            Assert.True(response is SuccessResponse);
            OnLog(response);
            Assert.True(newSchedule.Id > 0);

            await DeleteTemporarySchedule(newSchedule.Id);
        }
コード例 #2
0
        private async Task <int> CreateTemporarySchedule()
        {
            var request      = new CreateScheduleRequest();
            var commandState = HueRequestBuilder.Modify.Light(7).TurnOn().Build();
            var newSchedule  = new GetScheduleResponse
            {
                AutoDelete  = true,
                Name        = "temporary schedule",
                Description = "temporary schedule description",
                Timing      = ScheduleTiming.CreateNew(ScheduleTimingTypes.Alarm),
                Command     = new Command(commandState),
                Status      = ScheduleStatus.Enabled
            };

            newSchedule.Timing.BaseDate = DateTime.Now.AddDays(1);
            request.NewSchedule         = newSchedule;

            var response = await _client.GetResponseAsync(request);

            Assert.True(response is SuccessResponse, "response is SuccessResponse");
            OnLog(response);
            Assert.True(newSchedule.Id > 0, "new ID set");
            return(newSchedule.Id);
        }