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