コード例 #1
0
        public void ConcreteZoneChangeFunctionCommandTest13()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), false, false, false, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10));
            commands.Add(new PlaySoundCommand(new SimpleId(), false, false, false, true, true, true, true, new Address("100.2"), "http://www.imfeld.net/mp3_stream"));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, null, new TimeSpan(), new TimeSpan(), commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteZoneChangeFunction target = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);

            target.calculateFunction(DateTime.Now);

            zoneServer.distributeZoneState(new ZoneState(new Address("100.6"), true, 10, ZoneQuality.Online));
            zoneServer.distributeZoneState(new ZoneState(new Address("100.5"), false, 20, ZoneQuality.Online));
            zoneServer.distributeZoneState(new ZoneState(new Address("100.4"), true, 20, ZoneQuality.Offline));

            target.calculateFunction(DateTime.Now);

            Assert.AreEqual(true, target.Active);                                                               // function is "active"
            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);                                                 // OnValidityStart
            Assert.AreEqual("http://www.imfeld.net/mp3_stream", ((AudioDriverMock)audioDrivers[2]).Url);        // URL is playing
            Assert.AreEqual(true, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                                // URL is still playing
        }
コード例 #2
0
        public void ConcreteFunctionTest2()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), false, false, false, false, false, true, true, new Address("100.1"), "OFF", "100.6", 10));

            List <DayOfWeek> dayOfWeek = new List <DayOfWeek>();

            dayOfWeek.Add(DayOfWeek.Monday);
            dayOfWeek.Add(DayOfWeek.Tuesday);
            dayOfWeek.Add(DayOfWeek.Wednesday);
            dayOfWeek.Add(DayOfWeek.Thursday);
            dayOfWeek.Add(DayOfWeek.Friday);
            dayOfWeek.Add(DayOfWeek.Saturday);
            dayOfWeek.Add(DayOfWeek.Sunday);
            TimeSpan validFrom = new TimeSpan(0, 0, 1);     // NOTE: (0,0,0) is considered as "not set" (not used)
            TimeSpan validTo   = new TimeSpan(23, 59, 59);

            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, dayOfWeek, validFrom, validTo, commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteFunctionTestClass target = new ConcreteFunctionTestClass(function, zoneServer, audioDrivers);

            // no validity defined -> per default valid
            Assert.AreEqual(true, target.Active);
            Assert.AreEqual(true, target.isActiveAt(DateTime.Now));
            Assert.AreEqual(true, target.isFunctionActiveToday(DateTime.Now));
            Assert.AreEqual(true, target.isFunctionActiveToday(DateTime.Now));

            // Check configuration and mock objects
            Assert.AreEqual(1, target.Function.Commands.Count);
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);
        }
コード例 #3
0
        public void ConcreteFunctionTest10a()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), true, false, false, false, false, true, true, new Address("100.1"), "ON", "100.6", 10));

            List <DayOfWeek> dayOfWeek = null;
            TimeSpan         validFrom = new TimeSpan(0, 0, 0); // NOTE: (0,0,0) is considered as "not set" (not used)
            TimeSpan         validTo   = new TimeSpan(0, 0, 0);

            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, dayOfWeek, validFrom, validTo, commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteFunctionTestClass target = new ConcreteFunctionTestClass(function, zoneServer, audioDrivers);

            // no validity defined -> per default valid
            Assert.AreEqual(true, target.Active);

            // execute events ...
            target.onFunctionError();

            // Check configuration and mock objects
            Assert.AreEqual(1, target.Function.Commands.Count);
            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);
            Assert.AreEqual(true, zoneServer.ZoneStateList[0].PowerStatus);
        }
コード例 #4
0
        public void ConcreteZoneChangeFunctionCommandTest14()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), false, false, false, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10));
            commands.Add(new PlaySoundCommand(new SimpleId(), false, false, false, true, true, true, true, new Address("100.2"), "http://www.imfeld.net/mp3_stream"));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, null, new TimeSpan(14, 0, 0), new TimeSpan(15, 0, 0), commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteZoneChangeFunction target = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);

            target.calculateFunction(new DateTime(2016, 2, 24, 10, 0, 0));
            //Assert.AreEqual(false, target.Active);                                                              // function is not active
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);                                                 // no command in queue
            Assert.AreEqual("", ((AudioDriverMock)audioDrivers[2]).Url);                                        // no URL is playing
            Assert.AreEqual(false, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                               // not playing

            zoneServer.distributeZoneState(new ZoneState(new Address("100.6"), true, 10, ZoneQuality.Online));
            zoneServer.distributeZoneState(new ZoneState(new Address("100.5"), false, 20, ZoneQuality.Online));
            zoneServer.distributeZoneState(new ZoneState(new Address("100.4"), true, 20, ZoneQuality.Offline));

            target.calculateFunction(new DateTime(2016, 2, 24, 12, 0, 0));
            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 24, 12, 0, 0)));                     // function is not active
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);                                                 // no command in queue
            Assert.AreEqual("", ((AudioDriverMock)audioDrivers[2]).Url);                                        // no URL is playing
            Assert.AreEqual(false, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                               // not playing

            target.calculateFunction(new DateTime(2016, 2, 24, 13, 59, 59));
            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 24, 13, 59, 59)));                   // function is not active
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);                                                 // no command in queue
            Assert.AreEqual("", ((AudioDriverMock)audioDrivers[2]).Url);                                        // no URL is playing
            Assert.AreEqual(false, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                               // not playing

            target.calculateFunction(new DateTime(2016, 2, 24, 14, 0, 0));
            Assert.AreEqual(true, target.isActiveAt(new DateTime(2016, 2, 24, 14, 0, 0)));                      // function is active
            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);                                                 // one command in queue
            Assert.AreEqual("http://www.imfeld.net/mp3_stream", ((AudioDriverMock)audioDrivers[2]).Url);        // URL is playing
            Assert.AreEqual(true, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                                // is playing

            target.calculateFunction(new DateTime(2016, 2, 24, 14, 0, 1));
            Assert.AreEqual(true, target.isActiveAt(new DateTime(2016, 2, 24, 14, 0, 1)));                      // function not active
            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);                                                 // no new command in queue
            Assert.AreEqual("http://www.imfeld.net/mp3_stream", ((AudioDriverMock)audioDrivers[2]).Url);        // URL is still playing
            Assert.AreEqual(true, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                                // is playing

            target.calculateFunction(new DateTime(2016, 2, 24, 15, 0, 0));
            Assert.AreEqual(true, target.isActiveAt(new DateTime(2016, 2, 24, 15, 0, 0)));                      // function is active
            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);                                                 // one command in queue
            Assert.AreEqual("http://www.imfeld.net/mp3_stream", ((AudioDriverMock)audioDrivers[2]).Url);        // URL is playing
            Assert.AreEqual(true, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                                // is playing

            target.calculateFunction(new DateTime(2016, 2, 24, 15, 0, 1));
            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 24, 15, 0, 1)));                     // function not active anymore
            Assert.AreEqual(2, zoneServer.ZoneStateList.Count);                                                 // second command in queue
            Assert.AreEqual("", ((AudioDriverMock)audioDrivers[2]).Url);                                        // no URL is playing
            Assert.AreEqual(false, ((AudioDriverMock)audioDrivers[2]).IsPlaying);                               // not playing anymore
        }
コード例 #5
0
 public void notifyOnZoneUpdateTest1()
 {
     ZoneChangeFunction             function     = new ZoneChangeFunction();
     IZoneServer                    zoneServer   = null;
     Dictionary <int, IAudioDriver> audioDrivers = null;
     ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
     ZoneStateEventArgs             e            = new ZoneStateEventArgs(new ZoneState());
     // not supported anymore; quick-fix, uncomment unit test ->  target.notifyOnZoneUpdate(e);
     //ok, pass without exception
 }
コード例 #6
0
        public void notifyOnZoneUpdateTest1()
        {
            ZoneChangeFunction                  function     = new ZoneChangeFunction();
            IZoneServer                         zoneServer   = null;
            Dictionary <int, IAudioDriver>      audioDrivers = null;
            ConcreteZoneChangeFunction_Accessor target       = new ConcreteZoneChangeFunction_Accessor(function, zoneServer, audioDrivers);
            ZoneStateEventArgs                  e            = new ZoneStateEventArgs(new ZoneState());

            target.notifyOnZoneUpdate(e);
            //ok, pass without exception
        }
コード例 #7
0
        public void ConcreteZoneChangeFunctionConstructorTest()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), true, true, true, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, true, true, true, true, null, new TimeSpan(), new TimeSpan(), commands);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            // No exception
        }
コード例 #8
0
        public void ActiveTest1()
        {
            ZoneChangeFunction             function     = new ZoneChangeFunction();
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            bool actual;

            actual = target.Active;
            Assert.AreEqual(true, actual);
        }
コード例 #9
0
 /// <summary>
 /// Constructor to instantiate a concrete zone change function.
 /// </summary>
 /// <param name="function">Configuration data for this zone change function.</param>
 /// <param name="zoneServer">Zone server, to get notification about zone changes.</param>
 /// <param name="audioDrivers">Audio Drivers, in case a sound needs to be played.</param>
 public ConcreteZoneChangeFunction(ZoneChangeFunction function, IZoneServer zoneServer, Dictionary <int, IAudioDriver> audioDrivers)
     : base(zoneServer, function, audioDrivers)
 {
     if (function == null)
     {
         onFunctionError();
         throw new FunctionServerException("Function configuration is null. This is not allowed");
     }
     _function = function;
     subscribeZone(_function.ZoneId);
 }
コード例 #10
0
        public void FunctionTest()
        {
            ZoneChangeFunction             function     = new ZoneChangeFunction();
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            Function actual;

            actual = target.Function;
            Assert.IsNotNull(actual);
        }
コード例 #11
0
        public void ActiveTest6()
        {
            TimeSpan                       validFrom    = new TimeSpan(DateTime.Now.Hour - 1, 0, 0);
            TimeSpan                       validTo      = new TimeSpan(23, 59, 59);
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, null, validFrom, validTo, null);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            bool actual;

            actual = target.Active;
            Assert.AreEqual(true, actual);
        }
コード例 #12
0
        public void notifyOnZoneUpdateTest2()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), true, true, true, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, true, true, true, true, null, new TimeSpan(), new TimeSpan(), commands);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            ZoneStateEventArgs             e            = new ZoneStateEventArgs(new ZoneState());
            // not supported anymore; quick-fix, uncomment unit test -> target.notifyOnZoneUpdate(e); // init zone state
            // not supported anymore; quick-fix, uncomment unit test -> target.notifyOnZoneUpdate(e);
        }
コード例 #13
0
        public void ConcreteFunctionTest3()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), false, false, false, false, false, true, true, new Address("100.1"), "OFF", "100.6", 10));

            List <DayOfWeek> dayOfWeek = new List <DayOfWeek>();

            //dayOfWeek.Add(DayOfWeek.Monday); -> not valid on Monday
            dayOfWeek.Add(DayOfWeek.Tuesday);
            dayOfWeek.Add(DayOfWeek.Wednesday);
            dayOfWeek.Add(DayOfWeek.Thursday);
            dayOfWeek.Add(DayOfWeek.Friday);
            dayOfWeek.Add(DayOfWeek.Saturday);
            dayOfWeek.Add(DayOfWeek.Sunday);
            TimeSpan validFrom = new TimeSpan(0, 0, 1);     // NOTE: (0,0,0) is considered as "not set" (not used)
            TimeSpan validTo   = new TimeSpan(23, 59, 59);

            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, dayOfWeek, validFrom, validTo, commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteFunctionTestClass target = new ConcreteFunctionTestClass(function, zoneServer, audioDrivers);

            // 22.02.2016 is Monday
            //Assert.AreEqual(true, target.Active); --> works only with current date+time
            Assert.AreEqual(true, target.isActiveAt(new DateTime(2016, 2, 21, 23, 59, 59)));
            Assert.AreEqual(true, target.isFunctionActiveToday(new DateTime(2016, 2, 21, 23, 59, 59)));
            Assert.AreEqual(true, target.isFunctionActiveRightNow(new DateTime(2016, 2, 21, 23, 59, 59)));

            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 22, 0, 0, 0)));                  // considers TIME + DATE
            Assert.AreEqual(false, target.isFunctionActiveToday(new DateTime(2016, 2, 22, 0, 0, 0)));       // considers only DATE
            Assert.AreEqual(false, target.isFunctionActiveRightNow(new DateTime(2016, 2, 22, 0, 0, 0)));    // considers only TIME
            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 22, 23, 59, 59)));
            Assert.AreEqual(false, target.isFunctionActiveToday(new DateTime(2016, 2, 22, 23, 59, 59)));
            Assert.AreEqual(true, target.isFunctionActiveRightNow(new DateTime(2016, 2, 22, 23, 59, 58)));  // considers only TIME
            Assert.AreEqual(true, target.isFunctionActiveRightNow(new DateTime(2016, 2, 22, 23, 59, 59)));  // considers only TIME

            Assert.AreEqual(false, target.isActiveAt(new DateTime(2016, 2, 23, 0, 0, 0)));                  // considers TIME + DATE
            Assert.AreEqual(true, target.isActiveAt(new DateTime(2016, 2, 23, 0, 0, 1)));                   // considers TIME + DATE
            Assert.AreEqual(true, target.isFunctionActiveToday(new DateTime(2016, 2, 23, 0, 0, 0)));        // considers only DATE
            Assert.AreEqual(true, target.isFunctionActiveToday(new DateTime(2016, 2, 23, 0, 0, 1)));        // considers only DATE
            Assert.AreEqual(false, target.isFunctionActiveRightNow(new DateTime(2016, 2, 23, 0, 0, 0)));    // considers only TIME
            Assert.AreEqual(true, target.isFunctionActiveRightNow(new DateTime(2016, 2, 23, 0, 0, 1)));     // considers only TIME

            // Check configuration and mock objects
            Assert.AreEqual(1, target.Function.Commands.Count);
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);
        }
コード例 #14
0
        public void ActiveTest2()
        {
            List <DayOfWeek> dayOfWeek = new List <DayOfWeek>();

            dayOfWeek.Add(DateTime.Now.DayOfWeek);
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, dayOfWeek, null);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            bool actual;

            actual = target.Active;
            Assert.AreEqual(true, actual);
        }
コード例 #15
0
        public void ConcreteZoneChangeFunctionCommandTest7()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), true, true, true, true, true, true, true, new Address("100.1"), "OFF", "100.6", 10));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address("100.6"), 10, null, commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);

            zoneServer.distributeZoneState(new ZoneState(new Address("100.6"), true, 10, ZoneQuality.Online));
            zoneServer.distributeZoneState(new ZoneState(new Address("100.5"), false, 20, ZoneQuality.Online));

            target.calculateFunction(DateTime.Now);

            Assert.AreEqual(1, zoneServer.ZoneStateList.Count);     // OnValidityStart
        }
コード例 #16
0
        public void ActiveTest4()
        {
            List <DayOfWeek> dayOfWeek = new List <DayOfWeek>();

            dayOfWeek.Add(DayOfWeek.Monday);
            dayOfWeek.Add(DayOfWeek.Tuesday);
            dayOfWeek.Add(DayOfWeek.Wednesday);
            dayOfWeek.Add(DayOfWeek.Thursday);
            dayOfWeek.Add(DayOfWeek.Friday);
            dayOfWeek.Add(DayOfWeek.Saturday);
            dayOfWeek.Add(DayOfWeek.Sunday);
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, dayOfWeek, null);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            bool actual;

            actual = target.Active;
            Assert.AreEqual(true, actual);
        }
コード例 #17
0
        public void ConcreteFunctionTest1()
        {
            List <Command> commands = new List <Command>();

            commands.Add(new SendNuvoCommand(new SimpleId(), false, false, false, false, false, true, true, new Address("100.1"), "OFF", "100.6", 10));
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address("100.1"), new Address(), 0, true, true, true, true, null, new TimeSpan(), new TimeSpan(), commands);
            ZoneServerMock                 zoneServer   = new ZoneServerMock();
            Dictionary <int, IAudioDriver> audioDrivers = new Dictionary <int, IAudioDriver>();

            audioDrivers.Add(2, new AudioDriverMock());
            ConcreteFunctionTestClass target = new ConcreteFunctionTestClass(function, zoneServer, audioDrivers);

            // no validity defined -> per default valid
            Assert.AreEqual(true, target.Active);
            Assert.AreEqual(true, target.isActiveAt(DateTime.Now));
            Assert.AreEqual(true, target.isFunctionActiveToday(DateTime.Now));
            Assert.AreEqual(true, target.isFunctionActiveToday(DateTime.Now));

            // Check configuration and mock objects
            Assert.AreEqual(1, target.Function.Commands.Count);
            Assert.AreEqual(0, zoneServer.ZoneStateList.Count);
        }
コード例 #18
0
        public void ActiveTest9()
        {
            List <DayOfWeek> dayOfWeek = new List <DayOfWeek>();

            dayOfWeek.Add(DayOfWeek.Monday);
            dayOfWeek.Add(DayOfWeek.Tuesday);
            dayOfWeek.Add(DayOfWeek.Wednesday);
            dayOfWeek.Add(DayOfWeek.Thursday);
            dayOfWeek.Add(DayOfWeek.Friday);
            dayOfWeek.Add(DayOfWeek.Saturday);
            dayOfWeek.Add(DayOfWeek.Sunday);
            TimeSpan                       validFrom    = new TimeSpan(0, 0, 1); // NOTE: (0,0,0) is considered as "not set" (not used)
            TimeSpan                       validTo      = new TimeSpan(DateTime.Now.Hour - 1, 59, 59);
            ZoneChangeFunction             function     = new ZoneChangeFunction(new SimpleId(), new Address(), new Address(), 0, dayOfWeek, validFrom, validTo, null);
            IZoneServer                    zoneServer   = null;
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteZoneChangeFunction     target       = new ConcreteZoneChangeFunction(function, zoneServer, audioDrivers);
            bool actual;

            actual = target.Active;
            Assert.AreEqual(false, actual);
        }
コード例 #19
0
        public void GetConfigurationTest()
        {
            // If the system configuration version changes, you need to adapt/review this test case
            Assert.AreEqual("3.0", SystemConfiguration.VERSION);

            string file = @"NuvoControlKonfigurationUnitTest2.xml";
            ConfigurationLoader target = new ConfigurationLoader(file);
            SystemConfiguration systemConfiguration = target.GetConfiguration();

            Assert.AreEqual("3.0", systemConfiguration.ConfigurationVersion);

            TestContext.WriteLine("Testing device communication parameters...");
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].Id, 100);
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].Communication.BaudRate, 9600);
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].Communication.DataBits, 8);
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].Communication.ParityBit, 1);
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].Communication.ParityMode, "None");

            TestContext.WriteLine("Testing device protocol driver parameters...");
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].ProtocolDriver.Name, "Nuvo Essentia Protokoll Driver");
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].ProtocolDriver.AssemblyName, "NuvoControl.Server.ProtocolDriver");
            Assert.AreEqual(systemConfiguration.Hardware.Devices[0].ProtocolDriver.ClassName, "NuvoControl.Server.ProtocolDriver.NuvoEssentiaProtocolDriver");

            TestContext.WriteLine("Testing audio driver parameters...");
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].AudioDevices.Count);
            Assert.AreEqual(new Address(100, 1), systemConfiguration.Hardware.Devices[0].AudioDevices[0].Id);
            Assert.AreEqual(1, systemConfiguration.Hardware.Devices[0].AudioDevices[0].Id.ObjectId);
            Assert.AreEqual(new Address(100, 2), systemConfiguration.Hardware.Devices[0].AudioDevices[1].Id);
            Assert.AreEqual(2, systemConfiguration.Hardware.Devices[0].AudioDevices[1].Id.ObjectId);
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].AudioDevices[2].Id.ObjectId);
            Assert.AreEqual("hw:0,0", systemConfiguration.Hardware.Devices[0].AudioDevices[0].Device);

            TestContext.WriteLine("Testing osc driver parameters...");
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].OscDevices.Count);
            // OSC Client 1
            Assert.AreEqual(eOSCDeviceType.OSCClient, systemConfiguration.Hardware.Devices[0].OscDevices[0].DeviceType);
            Assert.AreEqual(2, systemConfiguration.Hardware.Devices[0].OscDevices[0].Id.ObjectId);
            Assert.AreEqual(9000, systemConfiguration.Hardware.Devices[0].OscDevices[0].SendPort);
            Assert.AreEqual(-1, systemConfiguration.Hardware.Devices[0].OscDevices[0].ListenPort);
            // OSC Server
            Assert.AreEqual(eOSCDeviceType.OSCServer, systemConfiguration.Hardware.Devices[0].OscDevices[2].DeviceType);
            Assert.AreEqual(1, systemConfiguration.Hardware.Devices[0].OscDevices[2].Id.ObjectId);
            Assert.AreEqual(9000, systemConfiguration.Hardware.Devices[0].OscDevices[2].SendPort);
            Assert.AreEqual(8000, systemConfiguration.Hardware.Devices[0].OscDevices[2].ListenPort);
            // OSC Client 2
            Assert.AreEqual(eOSCDeviceType.OSCClient, systemConfiguration.Hardware.Devices[0].OscDevices[1].DeviceType);
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].OscDevices[1].Id.ObjectId);
            Assert.AreEqual(9002, systemConfiguration.Hardware.Devices[0].OscDevices[1].SendPort);
            Assert.AreEqual(-1, systemConfiguration.Hardware.Devices[0].OscDevices[1].ListenPort);
            Assert.AreEqual(18, systemConfiguration.Hardware.Devices[0].OscDevices[1].OscDeviceLayouts.Count);

            TestContext.WriteLine("Testing device zone parameters...");
            Assert.AreEqual(12, systemConfiguration.Hardware.Devices[0].ZoneList.Count);
            Assert.AreEqual(1, systemConfiguration.Hardware.Devices[0].ZoneList[0].Id.ObjectId);
            Assert.AreEqual(2, systemConfiguration.Hardware.Devices[0].ZoneList[1].Id.ObjectId);
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].ZoneList[2].Id.ObjectId);
            Assert.AreEqual(4, systemConfiguration.Hardware.Devices[0].ZoneList[3].Id.ObjectId);
            Assert.AreEqual(5, systemConfiguration.Hardware.Devices[0].ZoneList[4].Id.ObjectId);
            Assert.AreEqual(6, systemConfiguration.Hardware.Devices[0].ZoneList[5].Id.ObjectId);
            Assert.AreEqual(7, systemConfiguration.Hardware.Devices[0].ZoneList[6].Id.ObjectId);
            Assert.AreEqual(8, systemConfiguration.Hardware.Devices[0].ZoneList[7].Id.ObjectId);
            Assert.AreEqual(9, systemConfiguration.Hardware.Devices[0].ZoneList[8].Id.ObjectId);
            Assert.AreEqual(10, systemConfiguration.Hardware.Devices[0].ZoneList[9].Id.ObjectId);
            Assert.AreEqual(11, systemConfiguration.Hardware.Devices[0].ZoneList[10].Id.ObjectId);
            Assert.AreEqual(12, systemConfiguration.Hardware.Devices[0].ZoneList[11].Id.ObjectId);

            TestContext.WriteLine("Testing device source parameters...");
            Assert.AreEqual(6, systemConfiguration.Hardware.Devices[0].Sources.Count);
            Assert.AreEqual(1, systemConfiguration.Hardware.Devices[0].Sources[0].Id.ObjectId);
            Assert.AreEqual(2, systemConfiguration.Hardware.Devices[0].Sources[1].Id.ObjectId);
            Assert.AreEqual(3, systemConfiguration.Hardware.Devices[0].Sources[2].Id.ObjectId);
            Assert.AreEqual(4, systemConfiguration.Hardware.Devices[0].Sources[3].Id.ObjectId);
            Assert.AreEqual(5, systemConfiguration.Hardware.Devices[0].Sources[4].Id.ObjectId);
            Assert.AreEqual(6, systemConfiguration.Hardware.Devices[0].Sources[5].Id.ObjectId);

            TestContext.WriteLine("Testing some graphic parameters...");
            Assert.AreEqual(2, systemConfiguration.Graphic.Building.Floors.Count);
            Assert.AreEqual("Wohnbereich", systemConfiguration.Graphic.Building.Floors[0].Name);
            Assert.AreEqual(@".\Images\Wohnbereich.bmp", systemConfiguration.Graphic.Building.Floors[0].FloorPlanPath);
            Assert.AreEqual("bmp", systemConfiguration.Graphic.Building.Floors[0].FloorPlanType);
            Assert.AreEqual(9, systemConfiguration.Graphic.Building.Floors[0].Zones.Count);
            Assert.AreEqual(new Address(100, 1), systemConfiguration.Graphic.Building.Floors[0].Zones[0].Id);
            Assert.AreEqual("Esszimmer", systemConfiguration.Graphic.Building.Floors[0].Zones[0].Name);
            Assert.AreEqual(@".\Images\Esszimmer.jpg", systemConfiguration.Graphic.Building.Floors[0].Zones[0].PicturePath);
            Assert.AreEqual("jpg", systemConfiguration.Graphic.Building.Floors[0].Zones[0].PictureType);
            Assert.AreEqual(4, systemConfiguration.Graphic.Building.Floors[0].Zones[0].FloorPlanCoordinates.Count);
            Assert.AreEqual(485, systemConfiguration.Graphic.Building.Floors[0].Zones[0].FloorPlanCoordinates[1].X);
            Assert.AreEqual(210, systemConfiguration.Graphic.Building.Floors[0].Zones[0].FloorPlanCoordinates[1].Y);
            Assert.AreEqual(6, systemConfiguration.Graphic.Sources.Count);
            Assert.AreEqual(new Address(100, 1), systemConfiguration.Graphic.Sources[0].Id);
            Assert.AreEqual("DAB Hama DIR3100", systemConfiguration.Graphic.Sources[0].Name);
            Assert.AreEqual(systemConfiguration.Graphic.Sources[0].PicturePath, @".\Images\Tuner.jpg");
            Assert.AreEqual(systemConfiguration.Graphic.Sources[0].PictureType, "jpg");


            TestContext.WriteLine("Testing some function parameters...");
            Assert.AreEqual(12, systemConfiguration.Functions.Count);
            SleepFunction sleepFct = systemConfiguration.Functions[0] as SleepFunction;

            Assert.AreEqual(new SimpleId("2445f69e-a5a7-465e-95be-9179913d3780"), sleepFct.Id);
            Assert.AreEqual(new Address(100, 3), sleepFct.ZoneId);
            Assert.AreEqual(new TimeSpan(0, 60, 0), sleepFct.SleepDuration);
            Assert.AreEqual(new TimeSpan(20, 00, 0), sleepFct.ValidFrom);
            Assert.AreEqual(new TimeSpan(2, 0, 0), sleepFct.ValidTo);
            Assert.AreEqual(1, sleepFct.Commands.Count);

            AlarmFunction alarmFct = systemConfiguration.Functions[3] as AlarmFunction;

            Assert.AreEqual(new SimpleId("11111111-0001-1111-1111-111111111111"), alarmFct.Id);
            Assert.AreEqual(new Address(100, 2), alarmFct.ZoneId);
            Assert.AreEqual(new TimeSpan(6, 45, 0), alarmFct.AlarmTime);
            Assert.AreEqual(new TimeSpan(2, 0, 0), alarmFct.AlarmDuration);
            Assert.AreEqual(new Address(100, 1), alarmFct.SourceId);
            Assert.AreEqual(1, alarmFct.ValidOnDays.Count);
            Assert.AreEqual(DayOfWeek.Monday, alarmFct.ValidOnDays[0]);
            Assert.AreEqual(1, alarmFct.Commands.Count);

            ZoneChangeFunction zonechangeFct = systemConfiguration.Functions[6] as ZoneChangeFunction;

            Assert.AreEqual(new SimpleId("1234"), zonechangeFct.Id);
            Assert.AreEqual(1, zonechangeFct.ValidOnDays.Count);
            Assert.AreEqual(DayOfWeek.Tuesday, zonechangeFct.ValidOnDays[0]);
            Assert.AreEqual(0, zonechangeFct.Commands.Count);

            OscEventFunction oscFunc = systemConfiguration.Functions[7] as OscEventFunction;

            Assert.AreEqual(new SimpleId("504"), oscFunc.Id);
            Assert.AreEqual(1, oscFunc.ValidOnDays.Count);
            Assert.AreEqual(DayOfWeek.Friday, oscFunc.ValidOnDays[0]);
            Assert.AreEqual(2, oscFunc.Commands.Count);

            OscEventFunction oscFunc2 = systemConfiguration.Functions[8] as OscEventFunction;

            Assert.AreEqual(new SimpleId("505"), oscFunc2.Id);
            Assert.AreEqual("/4/toggle3", oscFunc2.OscLabel);
            Assert.AreEqual(null, oscFunc2.ValidOnDays);
            Assert.AreEqual(1, oscFunc2.Commands.Count);

            OscEventFunction oscFunc3 = systemConfiguration.Functions[9] as OscEventFunction;

            Assert.AreEqual(new SimpleId("506"), oscFunc3.Id);
            Assert.AreEqual("/4/toggle5", oscFunc3.OscLabel);
            Assert.AreEqual("100.1", oscFunc3.OscDevice.ToString());
            Assert.AreEqual("SwitchOff", oscFunc3.OscEvent);
            Assert.AreEqual(null, oscFunc3.ValidOnDays);
            Assert.AreEqual(1, oscFunc3.Commands.Count);
        }