public async Task UnprovisionedRemainsTest() { BACNetTelemetryMsg ioTWorxBacNetMsg = new BACNetTelemetryMsg() { name = "Device_190130_AV_67", value = "180", status = "true", timestamp = DateTime.UtcNow.ToString("o") }; BACNetIoTHubMessage iotBacNetEventHubMessage = new BACNetIoTHubMessage( ioTWorxBacNetMsg, ed.SystemProperties, new Dictionary <string, object>()); var messages = new List <BACNetIoTHubMessage>() { { iotBacNetEventHubMessage } }; //Ensure this device is Provisioned as "Unprovisioned" and stays that way var provisionedDeviceDocuments = new List <DeviceDocument>() { { new DeviceDocument() { id = ioTWorxBacNetMsg.name, DeviceStatus = "Unprovisioned" } } }; await IoTWorxBuildingDataProcessingFunction.HandleMessageBatch( messages, provisionedDeviceDocuments, outputDeviceDocs, outputEvents, unprovisionedDeviceOutput, LoggerUtils.Logger <object>(), new CancellationToken()); //Unprovisioned devices should be written to the DocDb and remain in Unprovisioned state outputDeviceDocs.Items.Count.ShouldBe(1); DeviceDocument outDeviceDocument = outputDeviceDocs.Items[0]; outDeviceDocument.id.ShouldBe(ioTWorxBacNetMsg.name); outDeviceDocument.PresentValue.ShouldBe(ioTWorxBacNetMsg.value); outDeviceDocument.DeviceStatus.ShouldBe("Unprovisioned"); unprovisionedDeviceOutput.Items.Count.ShouldBe(1); //Don't send Unprovisioned device events downstream outputEvents.Items.Count.ShouldBe(0); }
public async Task ProvisionedDevicesTest() { //Create 2 messages, one for a provisioned and the other an unprovisioned device BACNetTelemetryMsg ioTWorxBacNetMsg = new BACNetTelemetryMsg() { name = "Device_190130_AV_67", value = "180", status = "true", timestamp = DateTime.UtcNow.ToString("o") }; BACNetIoTHubMessage provisionedIoTBacNetEventHubMessage = new BACNetIoTHubMessage( ioTWorxBacNetMsg, ed.SystemProperties, new Dictionary <string, object>()); var messages = new List <BACNetIoTHubMessage>() { { provisionedIoTBacNetEventHubMessage } }; //Ensure device 1 is "Provisioned" var provisionedDeviceDocuments = new List <DeviceDocument>() { { new DeviceDocument() { id = provisionedIoTBacNetEventHubMessage.BACNetMsg.name, DeviceStatus = "Provisioned" } } }; await IoTWorxBuildingDataProcessingFunction.HandleMessageBatch( messages, provisionedDeviceDocuments, outputDeviceDocs, outputEvents, unprovisionedDeviceOutput, LoggerUtils.Logger <object>(), new CancellationToken()); //Unprovisioned devices should be written to the DocDb and flagged accordingly outputDeviceDocs.Items.Count.ShouldBe(1); unprovisionedDeviceOutput.Items.Count.ShouldBe(0); DeviceDocument deviceDocument = outputDeviceDocs.Items[0]; deviceDocument.id.ShouldBe(provisionedIoTBacNetEventHubMessage.BACNetMsg.name); deviceDocument.PresentValue.ShouldBe(provisionedIoTBacNetEventHubMessage.BACNetMsg.value); deviceDocument.DeviceStatus.ShouldBe("true"); }