Index: pkg/analysis_server/test/protocol_test.dart |
diff --git a/pkg/analysis_server/test/protocol_test.dart b/pkg/analysis_server/test/protocol_test.dart |
index 5d6fd715bdbe4e9a5ba2fb37401a10031a1fad8d..2767cc72d1dd51bddac8332c53f0186e5304425e 100644 |
--- a/pkg/analysis_server/test/protocol_test.dart |
+++ b/pkg/analysis_server/test/protocol_test.dart |
@@ -22,6 +22,9 @@ main() { |
test('getRequiredParameter_defined', RequestTest.getRequiredParameter_defined); |
test('getRequiredParameter_undefined', RequestTest.getRequiredParameter_undefined); |
test('fromJson', RequestTest.fromJson); |
+ test('fromJson_invalidId', RequestTest.fromJson_invalidId); |
+ test('fromJson_invalidMethod', RequestTest.fromJson_invalidMethod); |
+ test('fromJson_invalidParams', RequestTest.fromJson_invalidParams); |
test('fromJson_withParams', RequestTest.fromJson_withParams); |
test('toJson', RequestTest.toJson); |
test('toJson_withParams', RequestTest.toJson_withParams); |
@@ -116,6 +119,24 @@ class RequestTest { |
expect(request.method, equals('aMethod')); |
} |
+ static void fromJson_invalidId() { |
+ String json = '{"id":{"one":"two"},"method":"aMethod","params":{"foo":"bar"}}'; |
+ Request request = new Request.fromString(json); |
+ expect(request, isNull); |
+ } |
+ |
+ static void fromJson_invalidMethod() { |
+ String json = '{"id":"one","method":{"boo":"aMethod"},"params":{"foo":"bar"}}'; |
+ Request request = new Request.fromString(json); |
+ expect(request, isNull); |
+ } |
+ |
+ static void fromJson_invalidParams() { |
+ String json = '{"id":"one","method":"aMethod","params":"foobar"}'; |
+ Request request = new Request.fromString(json); |
+ expect(request, isNull); |
+ } |
+ |
static void fromJson_withParams() { |
Request original = new Request('one', 'aMethod'); |
original.setParameter('foo', 'bar'); |