Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: pkg/analysis_server/test/operation/operation_analysis_test.dart

Issue 311653002: Extract analysis/notifications into a separate operation/file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweak for the test method name. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.operation.analysis;
6
7 import 'package:analysis_server/src/operation/operation_analysis.dart';
8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:typed_mock/typed_mock.dart';
11 import 'package:unittest/unittest.dart';
12
13 import '../reflective_tests.dart';
14
15 main() {
16 groupSep = ' | ';
17
18 group('errorToJson', () {
19 runReflectiveTests(Test_errorToJson);
20 });
21 }
22
23
24 @ReflectiveTestCase()
25 class Test_errorToJson {
26 Source source = new SourceMock();
27 AnalysisError analysisError = new AnalysisErrorMock();
28
29 setUp() {
30 // prepare Source
31 when(source.fullName).thenReturn('foo.dart');
32 // prepare AnalysisError
33 when(analysisError.source).thenReturn(source);
34 when(analysisError.errorCode).thenReturn(CompileTimeErrorCode.AMBIGUOUS_EXPO RT);
35 when(analysisError.message).thenReturn('my message');
36 when(analysisError.offset).thenReturn(10);
37 when(analysisError.length).thenReturn(20);
38 }
39
40 tearDown() {
41 source = null;
42 analysisError = null;
43 }
44
45 test_noCorrection() {
46 when(analysisError.correction).thenReturn('my correction');
47 Map<String, Object> json = errorToJson(analysisError);
48 expect(json, {
49 'file': 'foo.dart',
50 'errorCode': 'CompileTimeErrorCode.AMBIGUOUS_EXPORT',
51 'offset': 10,
52 'length': 20,
53 'message': 'my message',
54 'correction': 'my correction'});
55 }
56
57 test_withCorrection() {
58 Map<String, Object> json = errorToJson(analysisError);
59 expect(json, {
60 'file': 'foo.dart',
61 'errorCode': 'CompileTimeErrorCode.AMBIGUOUS_EXPORT',
62 'offset': 10,
63 'length': 20,
64 'message': 'my message'});
65 }
66 }
67
68
69 class SourceMock extends TypedMock implements Source {
70 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
71 }
72
73
74 class AnalysisErrorMock extends TypedMock implements AnalysisError {
75 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698