예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
            }
        }