public void notifyOnZoneUpdateTest()
        {
            SleepFunction function   = new SleepFunction();
            IZoneServer   zoneServer = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteSleepFunction_Accessor target       = new ConcreteSleepFunction_Accessor(function, zoneServer, audioDrivers);

            // notify the first time, the update time is set to the current update time
            ZoneStateEventArgs e1 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 20, NuvoControl.Common.ZoneQuality.Online));

            target.notifyOnZoneUpdate(e1);
            Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON);

            // notify volume change, the last zone change to On time stays the same
            ZoneStateEventArgs e2 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 30, NuvoControl.Common.ZoneQuality.Online));

            target.notifyOnZoneUpdate(e2);
            Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON);

            // notify switch off, the last zone change to On time stays the same
            ZoneStateEventArgs e3 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), false, 30, NuvoControl.Common.ZoneQuality.Online));

            target.notifyOnZoneUpdate(e3);
            Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON);

            // notify switch on, the last zone change to On time updates
            ZoneStateEventArgs e4 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 30, NuvoControl.Common.ZoneQuality.Online));

            target.notifyOnZoneUpdate(e4);
            Assert.AreEqual(e4.ZoneState.LastUpdate, target._lastZoneChangeToON);
        }
        public void calculateFunctionTest2()
        {
            SleepFunction function = new SleepFunction(SimpleId.NewGuid(), new Address(100, 1),
                                                       new TimeSpan(1, 0, 0), new TimeSpan(0, 0, 0), new TimeSpan(23, 59, 59));
            ZoneServerMock zoneServer = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteSleepFunction_Accessor target       = new ConcreteSleepFunction_Accessor(function, zoneServer, audioDrivers);

            // notify the first time, the update time is set to the current update time
            ZoneStateEventArgs e1 = new ZoneStateEventArgs(new NuvoControl.Common.ZoneState(new Address(100, 1), true, 20, NuvoControl.Common.ZoneQuality.Online));

            target.notifyOnZoneUpdate(e1);
            Assert.AreEqual(e1.ZoneState.LastUpdate, target._lastZoneChangeToON);

            DateTime aktTime = DateTime.Now;

            target.calculateFunction(aktTime);

            DateTime nextTime = DateTime.Now + new TimeSpan(1, 0, 0);

            target.calculateFunction(nextTime);

            Assert.AreEqual(1, zoneServer._monitoredZones.Count);                           // 1 zone monitored
            Assert.AreEqual(1, zoneServer.ZoneStates.Count);                                // 1 command issued
            Assert.AreEqual(false, zoneServer.ZoneStates[new Address(100, 1)].PowerStatus); // switch off
        }