|  | // Copyright 2019 The Fuchsia Authors. All rights reserved. | 
|  | // Use of this source code is governed by a BSD-style license that can be | 
|  | // found in the LICENSE file. | 
|  |  | 
|  | import 'dart:convert'; | 
|  | import 'dart:io'; | 
|  |  | 
|  | import 'package:sl4f/sl4f.dart'; | 
|  | import 'package:test/test.dart'; | 
|  |  | 
|  | void main(List<String> args) { | 
|  | HttpServer fakeServer; | 
|  | Sl4f sl4f; | 
|  |  | 
|  | setUp(() async { | 
|  | fakeServer = await HttpServer.bind('127.0.0.1', 18080); | 
|  | sl4f = Sl4f('127.0.0.1:18080', null); | 
|  | }); | 
|  |  | 
|  | tearDown(() async { | 
|  | await fakeServer.close(); | 
|  | }); | 
|  |  | 
|  | test('call RestartSession facade with no params', () { | 
|  | void handler(HttpRequest req) async { | 
|  | expect(req.contentLength, greaterThan(0)); | 
|  | final body = jsonDecode(await utf8.decoder.bind(req).join()); | 
|  | expect(body['method'], 'basemgr_facade.RestartSession'); | 
|  | expect(body['params'], null); | 
|  | req.response.write( | 
|  | jsonEncode({'id': body['id'], 'result': 'Success', 'error': null})); | 
|  | await req.response.close(); | 
|  | } | 
|  | fakeServer.listen(handler); | 
|  |  | 
|  | expect(Modular(sl4f).restartSession(), completion(equals('Success'))); | 
|  | }); | 
|  | } | 
|  |  |