Can be used to create any type of schedule command Use a raw jsonString as input dynamic dynamicCOmmand = new ExpandoObject(); dynamicCOmmand.status = 1; var jsonString = JsonConvert.SerializeObject(dynamicCOmmand); var commandBody = new GenericScheduleCommand(jsonString);
Inheritance: ICommandBody
		public void CanConvertToSceneCommand()
		{
			SceneCommand sceneCommand = new SceneCommand();
			sceneCommand.Scene = "test123";

			var json = JsonConvert.SerializeObject(sceneCommand);

			GenericScheduleCommand genericCommand = new GenericScheduleCommand(json);

			Assert.IsTrue(genericCommand.IsSceneCommand());
			Assert.IsNotNull(genericCommand.AsSceneCommand());

			var scene = genericCommand.AsSceneCommand();
			Assert.AreEqual(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.IsFalse(genericCommand.IsSceneCommand());
			Assert.IsNotNull(genericCommand.AsLightCommand());

			var light = genericCommand.AsLightCommand();
			Assert.AreEqual(lightCommand.Alert, light.Alert);
		}
Exemple #3
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);
	}