Exemple #1
0
        public void TemperatureSensorShouldWork()
        {
            TemperatureSensor temperatureSensor = new TemperatureSensor();

            Assert.AreEqual(false, temperatureSensor.IsOn(), "TemperatureSensor should start off!");
            temperatureSensor.SetOn();
            Assert.AreEqual(true, temperatureSensor.IsOn(), "TemperatureSensor should turn on with SetOn()!");
            temperatureSensor.SetOff();
            Assert.AreEqual(false, temperatureSensor.IsOn(), "TemperatureSensor should turn off with SetOff()!");
            Assert.Throws <InvalidOperationException>(() => temperatureSensor.Read(), "TemperatureSensor should throw an InvalidOperationException if Read when off!");
        }