Exemple #1
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);
        }
Exemple #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);
        }
Exemple #3
0
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        internal virtual ConcreteFunction CreateConcreteFunction()
        {
            IZoneServer zoneServer = null;
            Function    function   = new FunctionTestClass();
            Dictionary <int, IAudioDriver> audioDrivers = null;
            ConcreteFunction target = new ConcreteFunctionTestClass(function, zoneServer, audioDrivers);

            return(target);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }