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 usage.usage_impl_io_test; | 5 library usage.usage_impl_io_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:test/test.dart'; |
11 import 'package:usage/src/usage_impl_io.dart'; | 11 import 'package:usage/src/usage_impl_io.dart'; |
12 | 12 |
| 13 main() => defineTests(); |
| 14 |
13 void defineTests() { | 15 void defineTests() { |
14 group('IOPostHandler', () { | 16 group('IOPostHandler', () { |
15 test('sendPost', () { | 17 test('sendPost', () { |
16 var httpClient = new MockHttpClient(); | 18 var httpClient = new MockHttpClient(); |
17 IOPostHandler postHandler = new IOPostHandler(mockClient: httpClient); | 19 IOPostHandler postHandler = new IOPostHandler(mockClient: httpClient); |
18 Map args = {'utv': 'varName', 'utt': 123}; | 20 Map<String, dynamic> args = {'utv': 'varName', 'utt': 123}; |
19 return postHandler.sendPost('http://www.google.com', args).then((_) { | 21 return postHandler.sendPost('http://www.google.com', args).then((_) { |
20 expect(httpClient.sendCount, 1); | 22 expect(httpClient.sendCount, 1); |
21 }); | 23 }); |
22 }); | 24 }); |
23 }); | 25 }); |
24 | 26 |
25 group('IOPersistentProperties', () { | 27 group('IOPersistentProperties', () { |
26 test('add', () { | 28 test('add', () { |
27 IOPersistentProperties props = new IOPersistentProperties('foo_props'); | 29 IOPersistentProperties props = new IOPersistentProperties('foo_props'); |
28 props['foo'] = 'bar'; | 30 props['foo'] = 'bar'; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 67 |
66 class MockHttpClientResponse implements HttpClientResponse { | 68 class MockHttpClientResponse implements HttpClientResponse { |
67 final MockHttpClient client; | 69 final MockHttpClient client; |
68 MockHttpClientResponse(this.client); | 70 MockHttpClientResponse(this.client); |
69 Future drain([var futureValue]) { | 71 Future drain([var futureValue]) { |
70 client.sendCount++; | 72 client.sendCount++; |
71 return new Future.value(); | 73 return new Future.value(); |
72 } | 74 } |
73 noSuchMethod(Invocation invocation) { } | 75 noSuchMethod(Invocation invocation) { } |
74 } | 76 } |
OLD | NEW |