Skip to content

Commit

Permalink
feat(bacnet-services.spec): implement test coverage for cov-subscript…
Browse files Browse the repository at this point in the history
…ion and read-access-specification value types
  • Loading branch information
fh1ch committed Jun 4, 2017
1 parent b015f62 commit 6665a7c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/integration/read-property-multiple.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}]);
Expand Down
84 changes: 84 additions & 0 deletions test/unit/bacnet-services.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6665a7c

Please sign in to comment.