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); }
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); }
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); }