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 json_rpc_2.test.server.server_test; | 5 library json_rpc_2.test.server.server_test; |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:json_rpc_2/error_code.dart' as error_code; | 10 import 'package:json_rpc_2/error_code.dart' as error_code; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 })); | 82 })); |
83 }); | 83 }); |
84 | 84 |
85 test("doesn't return a result for a notification", () { | 85 test("doesn't return a result for a notification", () { |
86 controller.server.registerMethod('foo', (args) => 'result'); | 86 controller.server.registerMethod('foo', (args) => 'result'); |
87 | 87 |
88 expect(controller.handleRequest({ | 88 expect(controller.handleRequest({ |
89 'jsonrpc': '2.0', | 89 'jsonrpc': '2.0', |
90 'method': 'foo', | 90 'method': 'foo', |
91 'params': {} | 91 'params': {} |
92 }), completion(isNull)); | 92 }), doesNotComplete); |
93 }); | 93 }); |
94 | 94 |
95 test("includes the error data in the response", () { | 95 test("includes the error data in the response", () { |
96 controller.server.registerMethod('foo', (params) { | 96 controller.server.registerMethod('foo', (params) { |
97 throw new json_rpc.RpcException(5, 'Error message.', data: 'data value'); | 97 throw new json_rpc.RpcException(5, 'Error message.', data: 'data value'); |
98 }); | 98 }); |
99 | 99 |
100 expectErrorResponse(controller, { | 100 expectErrorResponse(controller, { |
101 'jsonrpc': '2.0', | 101 'jsonrpc': '2.0', |
102 'method': 'foo', | 102 'method': 'foo', |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 })); | 182 })); |
183 }); | 183 }); |
184 }); | 184 }); |
185 | 185 |
186 test("disallows multiple methods with the same name", () { | 186 test("disallows multiple methods with the same name", () { |
187 controller.server.registerMethod('foo', () => null); | 187 controller.server.registerMethod('foo', () => null); |
188 expect(() => controller.server.registerMethod('foo', () => null), | 188 expect(() => controller.server.registerMethod('foo', () => null), |
189 throwsArgumentError); | 189 throwsArgumentError); |
190 }); | 190 }); |
191 } | 191 } |
OLD | NEW |