Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: pkg/analysis_server/test/protocol_test.dart

Issue 389413002: Use HasToJson when set Reponse/Notification parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_result.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9e6036b74c1f7256ac7793f89145d3607d490ad4..8813a686e4dedc53bba83ca39ac3adfba261ee76 100644
--- a/pkg/analysis_server/test/protocol_test.dart
+++ b/pkg/analysis_server/test/protocol_test.dart
@@ -9,6 +9,7 @@ import 'dart:convert';
import 'package:analysis_server/src/protocol.dart';
import 'package:analysis_testing/reflective_tests.dart';
import 'package:unittest/unittest.dart';
+import 'package:analysis_server/src/collections.dart';
Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>());
@@ -105,6 +106,40 @@ class NotificationTest {
'event': 'foo'
}));
}
+
+ void test_setParameter_HasToJson() {
+ Notification notification = new Notification('foo');
+ notification.setParameter('my', new _MyHasToJsonObject(42));
+ expect(notification.toJson(), equals({
+ 'event': 'foo',
+ 'params': {
+ 'my': {
+ 'offset': 42
+ }
+ }
+ }));
+ }
+
+ void test_setParameter_Iterable_HasToJson() {
+ Notification notification = new Notification('foo');
+ notification.setParameter('my', [
+ new _MyHasToJsonObject(1),
+ new _MyHasToJsonObject(2),
+ new _MyHasToJsonObject(3)]);
+ expect(notification.toJson(), equals({
+ 'event': 'foo',
+ 'params': {
+ 'my': [{'offset': 1}, {'offset': 2}, {'offset': 3}]
+ }
+ }));
+ }
+}
+
+
+class _MyHasToJsonObject implements HasToJson {
+ int offset;
+ _MyHasToJsonObject(this.offset);
+ Map<String, Object> toJson() => {'offset': offset};
}
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_result.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698