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

Side by Side Diff: pkg/analysis_server/test/resource_test.dart

Issue 300853006: Tests for exceptional situations in MemoryResourceProvider. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
« no previous file with comments | « pkg/analysis_server/lib/src/resource.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 test.resource; 5 library test.resource;
6 6
7 import 'dart:io' as io; 7 import 'dart:io' as io;
8 8
9 import 'package:analysis_server/src/resource.dart'; 9 import 'package:analysis_server/src/resource.dart';
10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
11 import 'package:analyzer/src/generated/source_io.dart'; 11 import 'package:analyzer/src/generated/source_io.dart';
12 import 'package:path/path.dart'; 12 import 'package:path/path.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 main() { 15 main() {
16 groupSep = ' | '; 16 groupSep = ' | ';
17 17
18 group('MemoryResourceProvider', () { 18 group('MemoryResourceProvider', () {
19 MemoryResourceProvider provider; 19 MemoryResourceProvider provider;
20 20
21 setUp(() { 21 setUp(() {
22 provider = new MemoryResourceProvider(); 22 provider = new MemoryResourceProvider();
23 }); 23 });
24 24
25 test('MemoryResourceException', () {
26 var exception = new MemoryResourceException('/my/path', 'my message');
27 expect(exception.path, '/my/path');
28 expect(exception.message, 'my message');
29 expect(exception.toString(),
30 'MemoryResourceException(path=/my/path; message=my message)');
31 });
32
33 group('newFolder', () {
34 test('empty path', () {
35 expect(
36 () {
37 provider.newFolder('');
38 },
39 throwsA(new isInstanceOf<ArgumentError>())
40 );
41 });
42
43 test('not absolute', () {
44 expect(
45 () {
46 provider.newFolder('not/absolute');
47 },
48 throwsA(new isInstanceOf<ArgumentError>())
49 );
50 });
51
52 group('already exists', () {
53 test('as folder', () {
54 Folder folder = provider.newFolder('/my/folder');
55 Folder newFolder = provider.newFolder('/my/folder');
56 expect(newFolder, folder);
57 });
58
59 test('as file', () {
Brian Wilkerson 2014/05/27 19:32:26 Is it worth testing the creation of a file when a
60 File file = provider.newFile('/my/file', 'qwerty');
61 expect(
62 () {
63 provider.newFolder('/my/file');
64 },
65 throwsA(new isInstanceOf<ArgumentError>())
66 );
67 });
68 });
69 });
70
25 group('File', () { 71 group('File', () {
26 group('==', () { 72 group('==', () {
27 test('false', () { 73 test('false', () {
28 File fileA = provider.getResource('/fileA.txt'); 74 File fileA = provider.getResource('/fileA.txt');
29 File fileB = provider.getResource('/fileB.txt'); 75 File fileB = provider.getResource('/fileB.txt');
30 expect(fileA == new Object(), isFalse); 76 expect(fileA == new Object(), isFalse);
31 expect(fileA == fileB, isFalse); 77 expect(fileA == fileB, isFalse);
32 }); 78 });
33 79
34 test('true', () { 80 test('true', () {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 expect(children[1], _isFolder); 358 expect(children[1], _isFolder);
313 expect(children[2], _isFile); 359 expect(children[2], _isFile);
314 }); 360 });
315 }); 361 });
316 }); 362 });
317 } 363 }
318 364
319 var _isFile = new isInstanceOf<File>(); 365 var _isFile = new isInstanceOf<File>();
320 var _isFolder = new isInstanceOf<Folder>(); 366 var _isFolder = new isInstanceOf<Folder>();
321 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); 367 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>();
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/resource.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698