Index: generated/googleapis/test/playcustomapp/v1_test.dart |
diff --git a/generated/googleapis/test/playcustomapp/v1_test.dart b/generated/googleapis/test/playcustomapp/v1_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fdbd3b39a18978cc56d3ecaae3da3e8b8589a6ba |
--- /dev/null |
+++ b/generated/googleapis/test/playcustomapp/v1_test.dart |
@@ -0,0 +1,139 @@ |
+library googleapis.playcustomapp.v1.test; |
+ |
+import "dart:core" as core; |
+import "dart:collection" as collection; |
+import "dart:async" as async; |
+import "dart:convert" as convert; |
+ |
+import 'package:http/http.dart' as http; |
+import 'package:http/testing.dart' as http_testing; |
+import 'package:test/test.dart' as unittest; |
+ |
+import 'package:googleapis/playcustomapp/v1.dart' as api; |
+ |
+class HttpServerMock extends http.BaseClient { |
+ core.Function _callback; |
+ core.bool _expectJson; |
+ |
+ void register(core.Function callback, core.bool expectJson) { |
+ _callback = callback; |
+ _expectJson = expectJson; |
+ } |
+ |
+ async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
+ if (_expectJson) { |
+ return request.finalize() |
+ .transform(convert.UTF8.decoder) |
+ .join('') |
+ .then((core.String jsonString) { |
+ if (jsonString.isEmpty) { |
+ return _callback(request, null); |
+ } else { |
+ return _callback(request, convert.JSON.decode(jsonString)); |
+ } |
+ }); |
+ } else { |
+ var stream = request.finalize(); |
+ if (stream == null) { |
+ return _callback(request, []); |
+ } else { |
+ return stream.toBytes().then((data) { |
+ return _callback(request, data); |
+ }); |
+ } |
+ } |
+ } |
+} |
+ |
+http.StreamedResponse stringResponse( |
+ core.int status, core.Map<core.String, core.String> headers, core.String body) { |
+ var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
+ return new http.StreamedResponse(stream, status, headers: headers); |
+} |
+ |
+core.int buildCounterCustomApp = 0; |
+buildCustomApp() { |
+ var o = new api.CustomApp(); |
+ buildCounterCustomApp++; |
+ if (buildCounterCustomApp < 3) { |
+ o.languageCode = "foo"; |
+ o.title = "foo"; |
+ } |
+ buildCounterCustomApp--; |
+ return o; |
+} |
+ |
+checkCustomApp(api.CustomApp o) { |
+ buildCounterCustomApp++; |
+ if (buildCounterCustomApp < 3) { |
+ unittest.expect(o.languageCode, unittest.equals('foo')); |
+ unittest.expect(o.title, unittest.equals('foo')); |
+ } |
+ buildCounterCustomApp--; |
+} |
+ |
+ |
+main() { |
+ unittest.group("obj-schema-CustomApp", () { |
+ unittest.test("to-json--from-json", () { |
+ var o = buildCustomApp(); |
+ var od = new api.CustomApp.fromJson(o.toJson()); |
+ checkCustomApp(od); |
+ }); |
+ }); |
+ |
+ |
+ unittest.group("resource-AccountsCustomAppsResourceApi", () { |
+ unittest.test("method--create", () { |
+ // TODO: Implement tests for media upload; |
+ // TODO: Implement tests for media download; |
+ |
+ var mock = new HttpServerMock(); |
+ api.AccountsCustomAppsResourceApi res = new api.PlaycustomappApi(mock).accounts.customApps; |
+ var arg_request = buildCustomApp(); |
+ var arg_account = "foo"; |
+ mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
+ var obj = new api.CustomApp.fromJson(json); |
+ checkCustomApp(obj); |
+ |
+ var path = (req.url).path; |
+ var pathOffset = 0; |
+ var index; |
+ var subPart; |
+ unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
+ pathOffset += 1; |
+ |
+ var query = (req.url).query; |
+ var queryOffset = 0; |
+ var queryMap = {}; |
+ addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
+ parseBool(n) { |
+ if (n == "true") return true; |
+ if (n == "false") return false; |
+ if (n == null) return null; |
+ throw new core.ArgumentError("Invalid boolean: $n"); |
+ } |
+ if (query.length > 0) { |
+ for (var part in query.split("&")) { |
+ var keyvalue = part.split("="); |
+ addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
+ } |
+ } |
+ |
+ |
+ var h = { |
+ "content-type" : "application/json; charset=utf-8", |
+ }; |
+ var resp = convert.JSON.encode(buildCustomApp()); |
+ return new async.Future.value(stringResponse(200, h, resp)); |
+ }), true); |
+ res.create(arg_request, arg_account).then(unittest.expectAsync1(((api.CustomApp response) { |
+ checkCustomApp(response); |
+ }))); |
+ }); |
+ |
+ }); |
+ |
+ |
+} |
+ |