| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino 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.md file. | |
| 4 | |
| 5 /// Tests that [Settings] instances can be serialized and deserialized. | |
| 6 library fletch_tests.settings_persist; | |
| 7 | |
| 8 import 'dart:async' show Future; | |
| 9 | |
| 10 import 'dart:convert'; | |
| 11 | |
| 12 import 'package:fletchc/src/worker/developer.dart' show | |
| 13 Address, | |
| 14 DeviceType, | |
| 15 IncrementalMode, | |
| 16 Settings, | |
| 17 parseSettings; | |
| 18 | |
| 19 import 'package:fletchc/src/verbs/infrastructure.dart' show | |
| 20 fileUri; | |
| 21 | |
| 22 import 'package:expect/expect.dart'; | |
| 23 | |
| 24 void testSettingsRoundTrip(Settings settings) { | |
| 25 Settings before = settings; | |
| 26 Map<String, dynamic> json = before.toJson(); | |
| 27 Settings after = parseSettings(const JsonCodec().encode(json), | |
| 28 Uri.parse("file:///dummy.fletch-settings")); | |
| 29 Expect.equals(before.packages, after.packages); | |
| 30 Expect.listEquals(before.options, after.options); | |
| 31 Expect.mapEquals(before.constants, after.constants); | |
| 32 Expect.equals(before.deviceAddress, after.deviceAddress); | |
| 33 Expect.equals(before.deviceType, after.deviceType); | |
| 34 Expect.equals(before.incrementalMode, after.incrementalMode); | |
| 35 } | |
| 36 | |
| 37 Future<Null> main() async { | |
| 38 testSettingsRoundTrip(new Settings.empty()); | |
| 39 testSettingsRoundTrip(new Settings( | |
| 40 fileUri(".packages", Uri.base), | |
| 41 ["a", "b", "c"], | |
| 42 {"a": "A", "b": "b"}, | |
| 43 new Address("localhost", 8080), | |
| 44 DeviceType.embedded, | |
| 45 IncrementalMode.experimental)); | |
| 46 } | |
| OLD | NEW |