예제 #1
0
        public void GetRadioChannels_Returns_List_of_RadioChannel()
        {
            // Arrange
            var radioChannelsReference = new List <RadioChannel>()
            {
                new RadioChannel()
                {
                    Id = 1026, Url = "http://192.168.1.1/radio2.m3u8"
                },
                new RadioChannel()
                {
                    Id = 1027, Url = "http://192.168.1.1/radio3.m3u8"
                },
            };

            var miioDevice = new Mock <IMiioTransport>();

            var msg = "{\"result\":{\"chs\":[" +
                      "{\"id\":1025,\"type\":0,\"url\":\"http://192.168.1.1/radio1.m3u8\"}," +
                      "{\"id\":1026,\"type\":0,\"url\":\"http://192.168.1.1/radio2.m3u8\"}," +
                      "{\"id\":1027,\"type\":0,\"url\":\"http://192.168.1.1/radio3.m3u8\"}," +
                      "]}}";

            miioDevice.Setup(x => x.SendMessage(It.IsAny <string>())).Returns(msg);

            var miioGateway = new MiioGateway(miioDevice.Object);

            // Act
            var radioChannels = miioGateway.GetRadioChannels();

            // Assert
            miioDevice.Verify(x => x.SendMessage("{\"id\": 1, \"method\": \"get_channels\", \"params\": {\"start\":0}}"), Times.Once());

            Assert.Equal(radioChannelsReference, radioChannels);
        }