public void ViscaPacketComparsions() { ViscaPower power1 = new ViscaPower(0x01, OnOffMode.On); ViscaPower power2 = new ViscaPower(0x01, OnOffMode.On); Assert.That(power1.Equals(null), Is.False, "ViscaTxPacket.Equals returned true on null"); Assert.That(power1.Equals(power2), Is.True, "ViscaTxPacket.Equals returned not true on same commands"); Assert.That(power1 != null, Is.True, "Command is not null"); Assert.That(power1 == null, Is.False, "Command is not null"); Assert.That(null == power1, Is.False, "Command is not null"); Assert.That(power1 == power2, Is.True, "Commands are not equal"); }
public async Task Power_OnWithFeedback() { bool power = false; ViscaPower powerOnCmd = new ViscaPower(id, OnOffMode.On); visca.EnqueueCommand(powerOnCmd.OnCompletion(() => { power = true; })); Assert.That(sendQueue.TryTake(out byte[] powerPacket, 100), Is.True, "Timeout on sending data for Power On"); Assert.That(powerPacket.SequenceEqual(new byte[] { 0x81, 0x01, 0x04, 0x00, 0x02, 0xff }), Is.True, "Power On bytes sequence does not match expected"); // Respond Completion visca.ProcessIncomingData(new byte[] { 0x90, 0x50, 0xFF }); ViscaPowerInquiry powerInquiry = new ViscaPowerInquiry(id, new Action <OnOffMode>(mode => { power = mode; Console.WriteLine("Event: power: {0}", mode); })); visca.EnqueueCommand(powerInquiry); Assert.That(sendQueue.TryTake(out byte[] powerInquiryPacket, 100), Is.True, "Timeout on sending data for Power Inquiry"); Assert.That(powerInquiryPacket.SequenceEqual(new byte[] { 0x81, 0x09, 0x04, 0x00, 0xff }), Is.True, "Power Inquiry bytes sequence does not match expected"); // Respond Power is On visca.ProcessIncomingData(new byte[] { 0x90, 0x50, 0x02, 0xFF }); await Task.Delay(100); power.Should().Be(true); /* * using (var monitoredSubject = power.Monitor()) * { * // Send Power is ON * visca.ProcessIncomingData(new byte[] { 0x90, 0x50, 0x02, 0xFF }); * await Task.Delay(100); * monitoredSubject.Should().Raise("PowerChanged").WithSender(camera).WithArgs<ViscaCamera.OnOffEventArgs>(args => args.On == true); * } * camera.Power.Should().Be(true); */ }