From 6665a7cc24b40ce90024d56c1833fc28a66dfd50 Mon Sep 17 00:00:00 2001 From: Fabio Huser Date: Sun, 4 Jun 2017 15:05:16 +0200 Subject: [PATCH] feat(bacnet-services.spec): implement test coverage for cov-subscription and read-access-specification value types --- .../read-property-multiple.spec.js | 4 +- test/unit/bacnet-services.spec.js | 84 +++++++++++++++++++ 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/test/integration/read-property-multiple.spec.js b/test/integration/read-property-multiple.spec.js index a0879ff0..22c2edb0 100644 --- a/test/integration/read-property-multiple.spec.js +++ b/test/integration/read-property-multiple.spec.js @@ -37,8 +37,8 @@ describe('bacstack - readPropertyMultiple integration', function() { {value: 'PscDet(*)', type: 7} ]); expect(object[211]).to.deep.equal([ - {value: {value: {type: 5, instance: 0}, type: 12}, type: undefined}, - {value: {value: {type: 3, instance: 0}, type: 12}, type: undefined} + {value: {value: {type: 5, instance: 0}, type: 12}, type: 118}, + {value: {value: {type: 3, instance: 0}, type: 12}, type: 118} ]); expect(object[4930]).to.deep.equal([{value: 0, type: 9}]); expect(object[4941]).to.deep.equal([{value: 6, type: 9}]); diff --git a/test/unit/bacnet-services.spec.js b/test/unit/bacnet-services.spec.js index 70081e8f..83d57b7a 100644 --- a/test/unit/bacnet-services.spec.js +++ b/test/unit/bacnet-services.spec.js @@ -357,6 +357,90 @@ describe('bacstack - Services layer', function() { ] }); }); + + it('should successfully encode and decode a cov-subscription value', function() { + var buffer = utils.getBuffer(); + baServices.EncodeReadPropertyAcknowledge(buffer, {type: 222, instance: 3}, 152, 0xFFFFFFFF, [ + {Tag: 111, Value: { + Recipient: {net: 12, adr: [0, 1]}, + subscriptionProcessIdentifier: 3, + monitoredObjectIdentifier: {type: 2, instance: 1}, + monitoredProperty: {propertyIdentifier: 85, propertyArrayIndex: 0}, + IssueConfirmedNotifications: false, + TimeRemaining: 5, + COVIncrement: 1 + }}, + {Tag: 111, Value: { + Recipient: {net: 0xFFFF, adr: []}, + subscriptionProcessIdentifier: 3, + monitoredObjectIdentifier: {type: 2, instance: 1}, + monitoredProperty: {propertyIdentifier: 85, propertyArrayIndex: 5}, + IssueConfirmedNotifications: true, + TimeRemaining: 5 + }} + ]); + var result = baServices.DecodeReadPropertyAcknowledge(buffer.buffer, 0, buffer.offset); + delete result.len; + expect(result).to.deep.equal({ + objectId: { + type: 222, + instance: 3 + }, + property: { + propertyArrayIndex: 0xFFFFFFFF, + propertyIdentifier: 152 + }, + valueList: [ + {type: 111, value: { + recipient: {net: 12, adr: [0, 1]}, + subscriptionProcessIdentifier: 3, + monitoredObjectIdentifier: {type: 2, instance: 1}, + monitoredProperty: {propertyIdentifier: 85, propertyArrayIndex: 0}, + issueConfirmedNotifications: false, + timeRemaining: 5, + covIncrement: 1 + }, len: 33}, + {type: 111, value: { + recipient: {net: 0xFFFF, adr: []}, + subscriptionProcessIdentifier: 3, + monitoredObjectIdentifier: {type: 2, instance: 1}, + monitoredProperty: {propertyIdentifier: 85, propertyArrayIndex: 5}, + issueConfirmedNotifications: true, + timeRemaining: 5, + }, len: 27} + ] + }); + }); + + it('should successfully encode and decode a read-access-specification value', function() { + var buffer = utils.getBuffer(); + baServices.EncodeReadPropertyAcknowledge(buffer, {type: 223, instance: 90000}, 53, 0xFFFFFFFF, [ + {Tag: 115, Value: {objectIdentifier: {type: 3, instance: 0}, propertyReferences: []}}, + {Tag: 115, Value: {objectIdentifier: {type: 3, instance: 50000}, propertyReferences: [ + {propertyIdentifier: 85}, + {propertyIdentifier: 1, propertyArrayIndex: 2} + ]}}, + ]); + var result = baServices.DecodeReadPropertyAcknowledge(buffer.buffer, 0, buffer.offset); + delete result.len; + expect(result).to.deep.equal({ + objectId: { + type: 223, + instance: 90000 + }, + property: { + propertyArrayIndex: 0xFFFFFFFF, + propertyIdentifier: 53 + }, + valueList: [ + {type: 115, value: {objectIdentifier: {type: 3, instance: 0}, propertyReferences: []}, len: 7}, + {type: 115, value: {objectIdentifier: {type: 3, instance: 50000}, propertyReferences: [ + {propertyIdentifier: 85, propertyArrayIndex: 0xFFFFFFFF}, + {propertyIdentifier: 1, propertyArrayIndex: 2} + ]}, len: 13} + ] + }); + }); }); describe('ReadPropertyMultipleAcknowledge', function() {