| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.protocol; | 5 library test.protocol; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 expect(() => makeDatum({ | 418 expect(() => makeDatum({ |
| 419 'key1': 'value1', | 419 'key1': 'value1', |
| 420 'key2': 2 | 420 'key2': 2 |
| 421 }).asStringMap(), _throwsInvalidParameter); | 421 }).asStringMap(), _throwsInvalidParameter); |
| 422 expect(() => makeDatum({ | 422 expect(() => makeDatum({ |
| 423 'key1': 1, | 423 'key1': 1, |
| 424 'key2': 2 | 424 'key2': 2 |
| 425 }).asStringMap(), _throwsInvalidParameter); | 425 }).asStringMap(), _throwsInvalidParameter); |
| 426 expect(() => makeDatum([]).asStringMap(), _throwsInvalidParameter); | 426 expect(() => makeDatum([]).asStringMap(), _throwsInvalidParameter); |
| 427 } | 427 } |
| 428 |
| 429 @runTest |
| 430 static void asStringListMap() { |
| 431 setUp(); |
| 432 { |
| 433 var map = { |
| 434 'key1': ['value11', 'value12'], |
| 435 'key2': ['value21', 'value22'] |
| 436 }; |
| 437 expect(makeDatum(map).asStringListMap(), map); |
| 438 } |
| 439 { |
| 440 var map = { |
| 441 'key1': 10, |
| 442 'key2': 20 |
| 443 }; |
| 444 expect(() => makeDatum(map).asStringListMap(), _throwsInvalidParameter); |
| 445 } |
| 446 { |
| 447 var map = { |
| 448 'key1': [11, 12], |
| 449 'key2': [21, 22] |
| 450 }; |
| 451 expect(() => makeDatum(map).asStringListMap(), _throwsInvalidParameter); |
| 452 } |
| 453 } |
| 428 } | 454 } |
| 429 | 455 |
| 430 class ResponseTest { | 456 class ResponseTest { |
| 431 @runTest | 457 @runTest |
| 432 static void create_contextDoesNotExist() { | 458 static void create_contextDoesNotExist() { |
| 433 Response response = new Response.contextDoesNotExist(new Request('0', '')); | 459 Response response = new Response.contextDoesNotExist(new Request('0', '')); |
| 434 expect(response.id, equals('0')); | 460 expect(response.id, equals('0')); |
| 435 expect(response.error, isNotNull); | 461 expect(response.error, isNotNull); |
| 436 expect(response.toJson(), equals({ | 462 expect(response.toJson(), equals({ |
| 437 Response.ID: '0', | 463 Response.ID: '0', |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 original.setResult('foo', 'bar'); | 548 original.setResult('foo', 'bar'); |
| 523 Response response = new Response.fromJson(original.toJson()); | 549 Response response = new Response.fromJson(original.toJson()); |
| 524 expect(response.id, equals('myId')); | 550 expect(response.id, equals('myId')); |
| 525 Map<String, Object> result = response.result; | 551 Map<String, Object> result = response.result; |
| 526 expect(result.length, equals(1)); | 552 expect(result.length, equals(1)); |
| 527 expect(result['foo'], equals('bar')); | 553 expect(result['foo'], equals('bar')); |
| 528 } | 554 } |
| 529 } | 555 } |
| 530 | 556 |
| 531 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); | 557 Matcher _throwsRequestFailure = throwsA(new isInstanceOf<RequestFailure>()); |
| OLD | NEW |