Esempio n. 1
0
        public void AddRadioChannel_with_Id_less_than_1024_throws_exception()
        {
            // Arrange
            var miioGateway = new MiioGateway(new Mock <IMiioTransport>().Object);

            // Act
            Assert.Throws <ArgumentException>(() => miioGateway.AddRadioChannel(1000, "url here"));
        }
Esempio n. 2
0
        public void AddRadioChannel_with_existing_Id_throws_exception()
        {
            // Arrange
            var miioDevice  = new Mock <IMiioTransport>();
            var miioGateway = new MiioGateway(miioDevice.Object);

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

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

            // Act
            Assert.Throws <ArgumentException>(() => miioGateway.AddRadioChannel(1045, "http://192.168.1.1/radio.m3u8"));
        }
Esempio n. 3
0
        public void AddRadioChannel_Should_Not_Throw_Exceptions()
        {
            // Arrange
            var miioDevice  = new Mock <IMiioTransport>();
            var miioGateway = new MiioGateway(miioDevice.Object);
            var msg         = "{\"id\": 2, \"method\": \"add_channels\", \"params\": {\"chs\":[{\"id\":1045,\"url\":\"http://192.168.1.1/radio4.m3u8\",\"type\":0}]}}";

            miioDevice.Setup(x => x.SendMessage(It.Is <string>(s => s.Contains("get_channels"))))
            .Returns("{\"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.Is <string>(s => s.Contains("add_channels"))))
            .Returns("{\"result\":[\"ok\"],\"id\":2}");

            // Act
            miioGateway.AddRadioChannel(1045, "http://192.168.1.1/radio4.m3u8");

            // Assert
            miioDevice.Verify(x => x.SendMessage(msg), Times.Once());
        }