@@ -18,12 +18,8 @@ import "package:dart_wot/src/definitions/validation/validation_exception.dart";
1818import "package:test/test.dart" ;
1919
2020void main () {
21- group ("Consumed Thing Tests" , () {
22- setUp (() {
23- // Additional setup goes here.
24- });
25-
26- test ("Parse Interaction Affordances" , () async {
21+ group ("ConsumedThing should" , () {
22+ test ("parse Interaction Affordances" , () async {
2723 const thingDescriptionJson = {
2824 "@context" : [
2925 "https://www.w3.org/2022/wot/td/v1.1" ,
@@ -219,7 +215,7 @@ void main() {
219215 });
220216
221217 test (
222- "Use of URI Template Variables" ,
218+ "use URI Template Variables" ,
223219 () async {
224220 const thingDescriptionJson = {
225221 "@context" : ["http://www.w3.org/ns/td" ],
@@ -279,4 +275,50 @@ void main() {
279275 },
280276 skip: true , // TODO: Replace with test with local server
281277 );
278+
279+ test ("throw ArgumentErrors for missing Affordances" , () async {
280+ const thingDescriptionJson = {
281+ "@context" : "https://www.w3.org/2022/wot/td/v1.1" ,
282+ "title" : "Test Thing" ,
283+ "securityDefinitions" : {
284+ "nosec_sc" : {"scheme" : "nosec" },
285+ },
286+ "security" : "nosec_sc" ,
287+ };
288+
289+ final parsedTd = ThingDescription .fromJson (thingDescriptionJson);
290+
291+ final servient = Servient ();
292+ final wot = await servient.start ();
293+
294+ final consumedThing = await wot.consume (parsedTd);
295+
296+ expect (
297+ () async => await consumedThing.readProperty ("test" ),
298+ throwsArgumentError,
299+ );
300+
301+ expect (
302+ () async => await consumedThing.writeProperty (
303+ "test" ,
304+ null .asInteractionInput (),
305+ ),
306+ throwsArgumentError,
307+ );
308+
309+ expect (
310+ () async => await consumedThing.observeProperty ("test" , (_) => ()),
311+ throwsArgumentError,
312+ );
313+
314+ expect (
315+ () async => await consumedThing.invokeAction ("test" ),
316+ throwsArgumentError,
317+ );
318+
319+ expect (
320+ () async => await consumedThing.subscribeEvent ("test" , (_) => ()),
321+ throwsArgumentError,
322+ );
323+ });
282324}
0 commit comments