Beispiel #1
0
        public async Task CreateGenericScheduleSingle()
        {
            Schedule schedule = new Schedule();

            schedule.Name        = "t1";
            schedule.Description = "test";
            schedule.LocalTime   = new HueDateTime()
            {
                DateTime = DateTime.Now.AddDays(1)
            };
            schedule.Command = new InternalBridgeCommand();

            dynamic dynamicCOmmand = new ExpandoObject();

            dynamicCOmmand.status = 1;

            var jsonString  = JsonConvert.SerializeObject(dynamicCOmmand);
            var commandBody = new GenericScheduleCommand(jsonString);

            schedule.Command.Body    = commandBody;
            schedule.Command.Address = "/api/huelandspoor/lights/5/state";
            schedule.Command.Method  = HttpMethod.Put;

            var result = await _client.CreateScheduleAsync(schedule);

            Assert.IsNotNull(result);
        }
        public void CanConvertToSceneCommand()
        {
            SceneCommand sceneCommand = new SceneCommand();

            sceneCommand.Scene = "test123";

            var json = JsonConvert.SerializeObject(sceneCommand);

            GenericScheduleCommand genericCommand = new GenericScheduleCommand(json);

            Assert.True(genericCommand.IsSceneCommand());
            Assert.NotNull(genericCommand.AsSceneCommand());

            var scene = genericCommand.AsSceneCommand();

            Assert.Equal(sceneCommand.Scene, scene.Scene);
        }
        public void CanConvertToLightCommand()
        {
            LightCommand lightCommand = new LightCommand();

            lightCommand.Alert = Alert.Multiple;
            lightCommand.On    = true;

            var json = JsonConvert.SerializeObject(lightCommand);

            GenericScheduleCommand genericCommand = new GenericScheduleCommand(json);

            Assert.False(genericCommand.IsSceneCommand());
            Assert.NotNull(genericCommand.AsLightCommand());

            var light = genericCommand.AsLightCommand();

            Assert.Equal(lightCommand.Alert, light.Alert);
        }