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

Side by Side Diff: pkg/analysis_server/test/protocol_test.dart

Issue 477323005: Use generated classes to create requests in analysis server unit tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:analysis_server/src/services/json.dart'; 10 import 'package:analysis_server/src/services/json.dart';
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 expect(request, isNull); 496 expect(request, isNull);
497 } 497 }
498 498
499 void test_fromJson_invalidParams() { 499 void test_fromJson_invalidParams() {
500 String json = '{"id":"one","method":"aMethod","params":"foobar"}'; 500 String json = '{"id":"one","method":"aMethod","params":"foobar"}';
501 Request request = new Request.fromString(json); 501 Request request = new Request.fromString(json);
502 expect(request, isNull); 502 expect(request, isNull);
503 } 503 }
504 504
505 void test_fromJson_withParams() { 505 void test_fromJson_withParams() {
506 Request original = new Request('one', 'aMethod'); 506 Request original = new Request('one', 'aMethod', {'foo': 'bar'});
507 original.setParameter('foo', 'bar');
508 String json = JSON.encode(original.toJson()); 507 String json = JSON.encode(original.toJson());
509 Request request = new Request.fromString(json); 508 Request request = new Request.fromString(json);
510 expect(request.id, equals('one')); 509 expect(request.id, equals('one'));
511 expect(request.method, equals('aMethod')); 510 expect(request.method, equals('aMethod'));
512 expect(request.params, equals({'foo': 'bar'})); 511 expect(request.params, equals({'foo': 'bar'}));
513 } 512 }
514 513
515 void test_getRequiredParameter_defined() { 514 void test_getRequiredParameter_defined() {
516 String name = 'name'; 515 String name = 'name';
517 String value = 'value'; 516 String value = 'value';
518 Request request = new Request('0', ''); 517 Request request = new Request('0', '', {name: value});
519 request.setParameter(name, value);
520 expect(request.getRequiredParameter(name).datum, equals(value)); 518 expect(request.getRequiredParameter(name).datum, equals(value));
521 } 519 }
522 520
523 void test_getRequiredParameter_null() { 521 void test_getRequiredParameter_null() {
524 String name = 'name'; 522 String name = 'name';
525 Request request = new Request('0', ''); 523 Request request = new Request('0', '', {name: null});
526 request.setParameter(name, null);
527 expect(request.getRequiredParameter(name).datum, equals(null)); 524 expect(request.getRequiredParameter(name).datum, equals(null));
528 } 525 }
529 526
530 void test_getRequiredParameter_undefined() { 527 void test_getRequiredParameter_undefined() {
531 String name = 'name'; 528 String name = 'name';
532 Request request = new Request('0', ''); 529 Request request = new Request('0', '');
533 expect(() => request.getRequiredParameter(name), _throwsRequestFailure); 530 expect(() => request.getRequiredParameter(name), _throwsRequestFailure);
534 } 531 }
535 532
536 void test_toJson() { 533 void test_toJson() {
537 Request request = new Request('one', 'aMethod'); 534 Request request = new Request('one', 'aMethod');
538 expect(request.toJson(), equals({ 535 expect(request.toJson(), equals({
539 Request.ID: 'one', 536 Request.ID: 'one',
540 Request.METHOD: 'aMethod' 537 Request.METHOD: 'aMethod'
541 })); 538 }));
542 } 539 }
543 540
544 void test_toJson_withParams() { 541 void test_toJson_withParams() {
545 Request request = new Request('one', 'aMethod'); 542 Request request = new Request('one', 'aMethod', {'foo': 'bar'});
546 request.setParameter('foo', 'bar');
547 expect(request.toJson(), equals({ 543 expect(request.toJson(), equals({
548 Request.ID: 'one', 544 Request.ID: 'one',
549 Request.METHOD: 'aMethod', 545 Request.METHOD: 'aMethod',
550 Request.PARAMS: { 546 Request.PARAMS: {
551 'foo': 'bar' 547 'foo': 'bar'
552 } 548 }
553 })); 549 }));
554 } 550 }
555 } 551 }
556 552
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 response.setResult(resultName, resultValue); 667 response.setResult(resultName, resultValue);
672 expect(response.getResult(resultName), same(resultValue)); 668 expect(response.getResult(resultName), same(resultValue));
673 expect(response.toJson(), equals({ 669 expect(response.toJson(), equals({
674 Response.ID: '0', 670 Response.ID: '0',
675 Response.RESULT: { 671 Response.RESULT: {
676 resultName: resultValue 672 resultName: resultValue
677 } 673 }
678 })); 674 }));
679 } 675 }
680 } 676 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/edit/refactoring_test.dart ('k') | pkg/analysis_server/test/search/element_references_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698