Ejemplo n.º 1
0
        public void Test_Common()
        {
            var serialChannel = new SerialChannel();

            Assert.IsNotNull(serialChannel);

            var tempService = new TemperatureService(serialChannel, 5000);

            Assert.IsNotNull(tempService);
            Assert.AreEqual(tempService.Channel, serialChannel);

            var ledService = new LEDService(serialChannel, 1000);

            Assert.IsNotNull(ledService);
            Assert.AreEqual(ledService.Channel, serialChannel);
        }
Ejemplo n.º 2
0
        public void Test_TemperatureService()
        {
            float temperature = 0.0f;

            var tempChannel = new TestTempChannel();

            tempChannel.ReceivedData += delegate(object sender, DataReceivedEventArgs e) {
                temperature = e.Value;
            };
            Assert.IsNotNull(tempChannel);
            tempChannel.Open(string.Empty);

            var tempService = new TemperatureService(tempChannel, 1000);

            tempChannel.Services.Add(tempService);
            Assert.IsNotNull(tempService);
            tempService.Enabled = true;
            Thread.Sleep(2000);
            Assert.AreEqual(25.1111f, temperature);

            tempChannel.Close();
        }