| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'package:convert/convert.dart'; |
| 6 import 'package:test/test.dart'; |
| 7 |
| 8 void main() { |
| 9 var sink; |
| 10 setUp(() { |
| 11 sink = new AccumulatorSink<int>(); |
| 12 }); |
| 13 |
| 14 test("provides access to events as they're added", () { |
| 15 expect(sink.events, isEmpty); |
| 16 |
| 17 sink.add(1); |
| 18 expect(sink.events, equals([1])); |
| 19 |
| 20 sink.add(2); |
| 21 expect(sink.events, equals([1, 2])); |
| 22 |
| 23 sink.add(3); |
| 24 expect(sink.events, equals([1, 2, 3])); |
| 25 }); |
| 26 |
| 27 test("clear() clears the events", () { |
| 28 sink..add(1)..add(2)..add(3); |
| 29 expect(sink.events, equals([1, 2, 3])); |
| 30 |
| 31 sink.clear(); |
| 32 expect(sink.events, isEmpty); |
| 33 |
| 34 sink..add(4)..add(5)..add(6); |
| 35 expect(sink.events, equals([4, 5, 6])); |
| 36 }); |
| 37 |
| 38 test("indicates whether the sink is closed", () { |
| 39 expect(sink.isClosed, isFalse); |
| 40 sink.close(); |
| 41 expect(sink.isClosed, isTrue); |
| 42 }); |
| 43 |
| 44 test("doesn't allow add() to be called after close()", () { |
| 45 sink.close(); |
| 46 expect(() => sink.add(1), throwsStateError); |
| 47 }); |
| 48 } |
| OLD | NEW |