Exemple #1
0
        public void TestClearTestEvents()
        {
            ZigbeeDeviceBase testDevice = null;

            testHostService.OnDeviceLeft += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            testHostService.OnDeviceJoined += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            testHostService.ClearTestEvents();

            var createdDevice = new DemoZigbeeDeviceBase();

            testHostService.DeviceLeft(createdDevice);

            Assert.AreEqual(testDevice, null);

            testHostService.DeviceJoined(createdDevice);

            Assert.AreEqual(testDevice, null);
        }
        public void TestLabelPrinted()
        {
            ZigbeeDeviceBase validationDevice = null;
            int validationTesterId            = 0;
            int validationNetworkColorId      = 0;
            int validationProductionSiteId    = 0;

            testFinalizeService.OnLabelPrinted += delegate(ZigbeeDeviceBase device, int testerId, int networkColorId, int productionSiteId)
            {
                validationDevice           = device;
                validationTesterId         = testerId;
                validationNetworkColorId   = networkColorId;
                validationProductionSiteId = productionSiteId;
            };

            var testDevice           = new DemoZigbeeDeviceBase();
            var testTesterId         = 9;
            var testNetworkColorId   = 99;
            var testProductionSiteId = 999;

            testFinalizeService.LabelPrinted(testDevice, testTesterId, testNetworkColorId, testProductionSiteId);

            Assert.AreEqual(validationDevice, testDevice);
            Assert.AreEqual(validationTesterId, testTesterId);
            Assert.AreEqual(validationNetworkColorId, testNetworkColorId);
            Assert.AreEqual(validationProductionSiteId, testProductionSiteId);
        }
Exemple #3
0
        public void TestValidateDevice_ModelStringMessage_Success()
        {
            var device = new DemoZigbeeDeviceBase()
            {
                Address = TEST_ADDRESS,
                Eui     = new EmberEui64(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 })
            };

            deviceValidationService.ValidateDevice(device, modelStringMessage);

            Assert.AreEqual(device.ModelString, TEST_MODEL_STRING);
            mockEzspService.Verify(x => x.SendUnicast(EmberOutgoingMessageType.EMBER_OUTGOING_DIRECT, TEST_ADDRESS, It.IsAny <EmberApsFrame>(), 0, It.IsAny <byte[]>()));
        }
Exemple #4
0
        public void TestValidateDevice_FirmwareVersionMessage()
        {
            var device = new DemoZigbeeDeviceBase()
            {
                Address     = TEST_ADDRESS,
                Eui         = new EmberEui64(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 }),
                ModelString = TEST_MODEL_STRING
            };

            deviceValidationService.ValidateDevice(device, firmwareVersionMessage);

            Assert.IsTrue(device.Validated);
            Assert.AreEqual(device.LongFirmwareVersion, TEST_FIRMWARE_VERSION);
        }
Exemple #5
0
        public void TestDeviceLeft()
        {
            ZigbeeDeviceBase testDevice = null;

            testHostService.OnDeviceLeft += delegate(ZigbeeDeviceBase device)
            {
                testDevice = device;
            };

            var createdDevice = new DemoZigbeeDeviceBase();

            testHostService.DeviceLeft(createdDevice);

            Assert.AreEqual(createdDevice, testDevice);
        }
        public void TestRetrieveMessage()
        {
            var message = new EzspIncomingMessageHandlerResponse();
            var device  = new DemoZigbeeDeviceBase();

            messageQueueService.AddMessage(message, device);

            var tuple = messageQueueService.RetrieveMessage();

            Assert.AreEqual(tuple.Item1, message);
            Assert.AreEqual(tuple.Item2, device);

            tuple = messageQueueService.RetrieveMessage();

            Assert.AreEqual(tuple, null);
        }
        public void TestClearEvents()
        {
            ZigbeeDeviceBase validationDevice = default(ZigbeeDeviceBase);
            int?validationTesterId            = default(int?);
            int validationNetworkColorId      = default(int);
            int validationProductionSiteId    = default(int);
            int?validationSupervisorId        = default(int?);

            testFinalizeService.OnLabelPrinted += delegate(ZigbeeDeviceBase device, int testerId, int networkColorId, int productionSiteId)
            {
                validationDevice           = device;
                validationTesterId         = testerId;
                validationNetworkColorId   = networkColorId;
                validationProductionSiteId = productionSiteId;
            };

            testFinalizeService.OnSerialNumberGenerated += delegate(ZigbeeDeviceBase device, int?testerId, int?supervisorId)
            {
                validationDevice       = device;
                validationTesterId     = testerId;
                validationSupervisorId = supervisorId;
            };

            testFinalizeService.OnSerialNumberUpdated += delegate(ZigbeeDeviceBase device, int?testerId)
            {
                validationDevice   = device;
                validationTesterId = testerId;
            };

            var testDevice           = new DemoZigbeeDeviceBase();
            var testTesterId         = 9;
            var testNetworkColorId   = 99;
            var testProductionSiteId = 999;
            var testSupervisorId     = 99;

            testFinalizeService.ClearEvents();

            testFinalizeService.LabelPrinted(testDevice, testTesterId, testNetworkColorId, testProductionSiteId);
            testFinalizeService.SerialNumberGenerated(testDevice, testTesterId, testSupervisorId);
            testFinalizeService.SerialNumberUpdated(testDevice, testTesterId);

            Assert.AreEqual(validationDevice, default(ZigbeeDeviceBase));
            Assert.AreEqual(validationTesterId, default(int?));
            Assert.AreEqual(validationNetworkColorId, default(int));
            Assert.AreEqual(validationProductionSiteId, default(int));
            Assert.AreEqual(validationSupervisorId, default(int?));
        }
        public void TestClearConsumerEvents()
        {
            bool messageAddedEventCalled = false;

            messageQueueService.MessageAddedEvent += delegate()
            {
                messageAddedEventCalled = true;
            };

            messageQueueService.ClearConsumerEvents();

            var message = new EzspIncomingMessageHandlerResponse();
            var device  = new DemoZigbeeDeviceBase();

            messageQueueService.AddMessage(message, device);

            Assert.IsFalse(messageAddedEventCalled);
        }
        public void TestSerialNumberUpdated()
        {
            ZigbeeDeviceBase validationDevice = null;
            int?validationTesterId            = null;

            testFinalizeService.OnSerialNumberUpdated += delegate(ZigbeeDeviceBase device, int?testerId)
            {
                validationDevice   = device;
                validationTesterId = testerId;
            };

            var testDevice   = new DemoZigbeeDeviceBase();
            var testTesterId = 9;

            testFinalizeService.SerialNumberUpdated(testDevice, testTesterId);

            Assert.AreEqual(validationDevice, testDevice);
            Assert.AreEqual(validationTesterId, testTesterId);
        }
Exemple #10
0
        public void TestValidateDevice_IEEEAddressMessage()
        {
            bool deviceAddedEventCalled = false;

            deviceValidationService.OnAddDevice += delegate(ZigbeeDeviceBase testDevice)
            {
                deviceAddedEventCalled = true;
            };

            var device = new DemoZigbeeDeviceBase()
            {
                Address = TEST_ADDRESS
            };

            deviceValidationService.ValidateDevice(device, ieeeAddressMessage);

            Assert.IsTrue(deviceAddedEventCalled);
            Assert.AreEqual(device.Eui.ToString(), TEST_EUI);
            mockEzspService.Verify(x => x.SendUnicast(EmberOutgoingMessageType.EMBER_OUTGOING_DIRECT, TEST_ADDRESS, It.IsAny <EmberApsFrame>(), 0, It.IsAny <byte[]>()));
        }
        public void TestAddMessage()
        {
            bool messageAddedEventCalled = false;

            messageQueueService.MessageAddedEvent += delegate()
            {
                messageAddedEventCalled = true;
            };

            var message = new EzspIncomingMessageHandlerResponse();
            var device  = new DemoZigbeeDeviceBase();

            messageQueueService.AddMessage(message, device);

            var messages = (Queue <Tuple <EzspIncomingMessageHandlerResponse, ZigbeeDeviceBase> >) typeof(MessageQueueService).GetField("Messages", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(messageQueueService);

            Assert.IsTrue(messageAddedEventCalled);
            Assert.AreEqual(messages.Peek().Item1, message);
            Assert.AreEqual(messages.Peek().Item2, device);
        }
Exemple #12
0
        public void TestValidateDevice_ModelStringMessage_Failure()
        {
            bool deviceRemovedEventCalled = false;

            deviceValidationService.OnRemoveDevice += delegate(ZigbeeDeviceBase testDevice)
            {
                deviceRemovedEventCalled = true;
            };

            var device = new DemoZigbeeDeviceBase()
            {
                Address = TEST_ADDRESS,
                Eui     = new EmberEui64(new byte[] { 255, 255, 255, 255, 255, 255, 255, 255 })
            };

            deviceValidationService.ValidProduct = new Product()
            {
                ModelString = "Not TestModelString"
            };
            deviceValidationService.ValidateDevice(device, modelStringMessage);

            Assert.IsTrue(deviceRemovedEventCalled);
            mockEzspService.Verify(x => x.SendUnicast(EmberOutgoingMessageType.EMBER_OUTGOING_DIRECT, TEST_ADDRESS, It.IsAny <EmberApsFrame>(), 0, It.IsAny <byte[]>()));
        }