| OLD | NEW |
| (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 testing.mocks; | |
| 6 | |
| 7 import 'package:analyzer/src/generated/element.dart'; | |
| 8 import 'package:analyzer/src/generated/engine.dart'; | |
| 9 import 'package:analyzer/src/generated/source.dart'; | |
| 10 import 'package:typed_mock/typed_mock.dart'; | |
| 11 | |
| 12 | |
| 13 class MockAnalysisContext extends StringTypedMock implements AnalysisContext { | |
| 14 MockAnalysisContext(String name) : super(name); | |
| 15 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 16 } | |
| 17 | |
| 18 | |
| 19 class MockClassElement extends TypedMock implements ClassElement { | |
| 20 final ElementKind kind = ElementKind.CLASS; | |
| 21 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 22 } | |
| 23 | |
| 24 | |
| 25 class MockCompilationUnitElement extends TypedMock implements | |
| 26 CompilationUnitElement { | |
| 27 final ElementKind kind = ElementKind.COMPILATION_UNIT; | |
| 28 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 29 } | |
| 30 | |
| 31 | |
| 32 class MockConstructorElement extends TypedMock implements ConstructorElement { | |
| 33 final kind = ElementKind.CONSTRUCTOR; | |
| 34 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 35 } | |
| 36 | |
| 37 | |
| 38 class MockElement extends StringTypedMock implements Element { | |
| 39 MockElement([String name = '<element>']) : super(name); | |
| 40 | |
| 41 @override | |
| 42 String get displayName => _toString; | |
| 43 | |
| 44 @override | |
| 45 String get name => _toString; | |
| 46 | |
| 47 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 48 } | |
| 49 | |
| 50 | |
| 51 class MockFieldElement extends TypedMock implements FieldElement { | |
| 52 final ElementKind kind = ElementKind.FIELD; | |
| 53 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 54 } | |
| 55 | |
| 56 | |
| 57 class MockFunctionElement extends TypedMock implements FunctionElement { | |
| 58 final ElementKind kind = ElementKind.FUNCTION; | |
| 59 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 60 } | |
| 61 | |
| 62 | |
| 63 class MockFunctionTypeAliasElement extends TypedMock implements | |
| 64 FunctionTypeAliasElement { | |
| 65 final ElementKind kind = ElementKind.FUNCTION_TYPE_ALIAS; | |
| 66 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 67 } | |
| 68 | |
| 69 | |
| 70 class MockHtmlElement extends TypedMock implements HtmlElement { | |
| 71 final ElementKind kind = ElementKind.HTML; | |
| 72 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 73 } | |
| 74 | |
| 75 | |
| 76 class MockImportElement extends TypedMock implements ImportElement { | |
| 77 final ElementKind kind = ElementKind.IMPORT; | |
| 78 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 79 } | |
| 80 | |
| 81 | |
| 82 class MockLibraryElement extends TypedMock implements LibraryElement { | |
| 83 final ElementKind kind = ElementKind.LIBRARY; | |
| 84 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 85 } | |
| 86 | |
| 87 | |
| 88 class MockLocalVariableElement extends TypedMock implements LocalVariableElement | |
| 89 { | |
| 90 final ElementKind kind = ElementKind.LOCAL_VARIABLE; | |
| 91 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 92 } | |
| 93 | |
| 94 | |
| 95 class MockLogger extends TypedMock implements Logger { | |
| 96 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 97 } | |
| 98 | |
| 99 | |
| 100 class MockMethodElement extends StringTypedMock implements MethodElement { | |
| 101 final kind = ElementKind.METHOD; | |
| 102 MockMethodElement([String name = 'method']) : super(name); | |
| 103 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 104 } | |
| 105 | |
| 106 | |
| 107 class MockParameterElement extends TypedMock implements ParameterElement { | |
| 108 final ElementKind kind = ElementKind.PARAMETER; | |
| 109 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 110 } | |
| 111 | |
| 112 | |
| 113 class MockPropertyAccessorElement extends TypedMock implements | |
| 114 PropertyAccessorElement { | |
| 115 final ElementKind kind; | |
| 116 MockPropertyAccessorElement(this.kind); | |
| 117 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 118 } | |
| 119 | |
| 120 | |
| 121 class MockSource extends StringTypedMock implements Source { | |
| 122 MockSource([String name = 'mocked.dart']) : super(name); | |
| 123 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 124 } | |
| 125 | |
| 126 | |
| 127 class MockTopLevelVariableElement extends TypedMock implements | |
| 128 TopLevelVariableElement { | |
| 129 final ElementKind kind = ElementKind.TOP_LEVEL_VARIABLE; | |
| 130 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 131 } | |
| 132 | |
| 133 | |
| 134 class MockTypeParameterElement extends TypedMock implements TypeParameterElement | |
| 135 { | |
| 136 final ElementKind kind = ElementKind.TYPE_PARAMETER; | |
| 137 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 138 } | |
| 139 | |
| 140 | |
| 141 class StringTypedMock extends TypedMock { | |
| 142 String _toString; | |
| 143 | |
| 144 StringTypedMock(this._toString); | |
| 145 | |
| 146 @override | |
| 147 String toString() { | |
| 148 if (_toString != null) { | |
| 149 return _toString; | |
| 150 } | |
| 151 return super.toString(); | |
| 152 } | |
| 153 } | |
| OLD | NEW |