public async Task SetGroupStateTest() { IHueRequest request = new SetGroupStateRequest(3, new SetGroupState { IsOn = false }); IHueResponse response = await _client.GetResponseAsync(request); Assert.True(response is SuccessResponse); OnLog(response); }
public async Task SetGroupTest() { IHueRequest request = new GetGroupRequest(1); IHueResponse response = await _client.GetResponseAsync(request); OnLog(response); request = new SetGroupRequest((GetGroupResponse)response); ((SetGroupRequest)request).NewName = "Testname"; response = await _client.GetResponseAsync(request); Assert.True(response is SuccessResponse); OnLog(response); }
public async Task CreateAndDeleteGroupTest() { IHueRequest request = new CreateGroupRequest("tmp testgroup", 6, 7); IHueResponse response = await _client.GetResponseAsync(request); Assert.True(response is SuccessResponse); var newGroupId = Convert.ToInt32(((SuccessResponse)response)["id"]); request = new DeleteGroupRequest(newGroupId); await Assert.ThrowsAsync <ArgumentException>(async() => response = await _client.GetResponseAsync(request)); ((DeleteGroupRequest)request).Acknowledge(); response = await _client.GetResponseAsync(request); Assert.True(response is SuccessResponse); OnLog(response); }
protected void OnLog(IHueResponse response) { switch (response) { case GetGroupResponse getGroupResponse: OnLog(ToString(getGroupResponse)); break; case GetAllGroupsResponse getAllGroupsResponse: OnLog(ToString(getAllGroupsResponse)); break; case IHueStatusMessage statusMessage: OnLog(ToString(statusMessage)); break; case ICollection <Light> lightCollection: OnLog(ToString(lightCollection)); break; case GetAllScenesResponse getAllScenesResponse: OnLog(ToString(getAllScenesResponse)); break; case GetAllSchedulesResponse getAllSchedulesResponse: OnLog(ToString(getAllSchedulesResponse)); break; case GetAllSensorsResponse getAllSensorsResponse: OnLog(ToString(getAllSensorsResponse)); break; case SuccessResponse successResponse: OnLog(ToString(successResponse)); break; } }