From 845444c736a403c4a8109c2922bddbe400cf34f7 Mon Sep 17 00:00:00 2001 From: Mircea MATEI Date: Tue, 2 Apr 2019 15:11:17 +0300 Subject: [PATCH] #19. Fixing test --- src/lib/generator/writers/proxy_writer.dart | 4 +-- src/pubspec.yaml | 2 +- .../flutter_sqlite_m8_generator_test.dart | 30 ++++++++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/lib/generator/writers/proxy_writer.dart b/src/lib/generator/writers/proxy_writer.dart index f0a33ba..42fc164 100644 --- a/src/lib/generator/writers/proxy_writer.dart +++ b/src/lib/generator/writers/proxy_writer.dart @@ -24,12 +24,12 @@ class ProxyWriter extends EntityWriter { class ${emittedEntity.modelName}Proxy extends ${emittedEntity.modelName} { Map toMap() { var map = new Map(); - ${this._getToMapList()} +${this._getToMapList()} return map; } ${emittedEntity.modelName}Proxy.fromMap(Map map) { - ${this._getFromMapList()} +${this._getFromMapList()} } } diff --git a/src/pubspec.yaml b/src/pubspec.yaml index d77d94b..b8bb8bb 100644 --- a/src/pubspec.yaml +++ b/src/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_sqlite_m8_generator description: Flutter package to generate SQLite fixture in conjuction with the package flutter_orm_m8. -version: 0.0.5 +version: 0.0.6 author: Mircea-Tiberiu MATEI homepage: https://github.com/matei-tm/flutter-sqlite-m8-generator diff --git a/src/test/flutter_sqlite_m8_generator_test.dart b/src/test/flutter_sqlite_m8_generator_test.dart index 8c32785..f1f9444 100644 --- a/src/test/flutter_sqlite_m8_generator_test.dart +++ b/src/test/flutter_sqlite_m8_generator_test.dart @@ -21,6 +21,22 @@ import 'dart:async'; /*import 'package:todo_currentProjectPackage_path/abstract_database_helper.dart';*/ import 'package:__test__/account_related.dart'; +class HealthEntryAccountRelatedProxy extends HealthEntryAccountRelated { + Map toMap() { + var map = new Map(); + map['my_id_column'] = id; + map['my_description_column'] = description; + map['my_account_id_column'] = accountId; + return map; + } + + HealthEntryAccountRelatedProxy.fromMap(Map map) { + this.id = map['my_id_column']; + this.description = map['my_description_column']; + this.accountId = map['my_account_id_column']; + } +} + mixin HealthEntryAccountRelatedDatabaseHelper /*implements AbstractDatabaseHelper*/ { Future db; final theHealthEntryAccountRelatedColumns = ["my_id_column", "my_description_column", "my_account_id_column"]; @@ -31,7 +47,7 @@ mixin HealthEntryAccountRelatedDatabaseHelper /*implements AbstractDatabaseHelpe await db.execute('CREATE TABLE $_theHealthEntryAccountRelatedTableHandler (my_id_column INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, my_description_column TEXT UNIQUE, my_account_id_column INTEGER NOT NULL)'); } - Future saveHealthEntryAccountRelated(HealthEntryAccountRelated instanceHealthEntryAccountRelated) async { + Future saveHealthEntryAccountRelated(HealthEntryAccountRelatedProxy instanceHealthEntryAccountRelated) async { var dbClient = await db; var result = await dbClient.insert(_theHealthEntryAccountRelatedTableHandler, instanceHealthEntryAccountRelated.toMap()); return result; @@ -66,11 +82,9 @@ var dbClient = await db; List result = await dbClient.query(_theHealthEntryAccountRelatedTableHandler, columns: theHealthEntryAccountRelatedColumns, where: 'my_id_column = ? AND is_deleted != 1', whereArgs: [id]); -/* if (result.length > 0) { - return HealthEntryAccountRelated.fromMap(result.first); + return HealthEntryAccountRelatedProxy.fromMap(result.first); } -*/ return null; } @@ -87,7 +101,7 @@ await dbClient.delete(_theHealthEntryAccountRelatedTableHandler); return true; } - Future updateHealthEntryAccountRelated(HealthEntryAccountRelated instanceHealthEntryAccountRelated) async { + Future updateHealthEntryAccountRelated(HealthEntryAccountRelatedProxy instanceHealthEntryAccountRelated) async { var dbClient = await db; return await dbClient.update(_theHealthEntryAccountRelatedTableHandler, instanceHealthEntryAccountRelated.toMap(), where: "my_id_column = ?", whereArgs: [instanceHealthEntryAccountRelated.id]); @@ -102,11 +116,7 @@ map['is_deleted'] = 1; return await dbClient .update(_theHealthEntryAccountRelatedTableHandler, map, where: "my_id_column = ?", whereArgs: [id]); } -} - - -// Entity:my_account_related_table Model:HealthEntryAccountRelated -//{_id: Instance of 'EntityAttribute', _description: Instance of 'EntityAttribute', _accountId: Instance of 'EntityAttribute'}'''; +}'''; expect(output, expected); });