From 2ad8d9a9210896ed9ce9bf0c5bdec0f00d417291 Mon Sep 17 00:00:00 2001 From: Pedro Date: Wed, 13 Mar 2019 10:16:33 -0300 Subject: [PATCH] Test unit -> LoadFromJSONArrayStringItems --- ...ework.Tests.Serializer.JsonDataObjects.pas | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/unittests/serializer/jsondataobjects/MVCFramework.Tests.Serializer.JsonDataObjects.pas b/unittests/serializer/jsondataobjects/MVCFramework.Tests.Serializer.JsonDataObjects.pas index acca1d9d..81e099de 100644 --- a/unittests/serializer/jsondataobjects/MVCFramework.Tests.Serializer.JsonDataObjects.pas +++ b/unittests/serializer/jsondataobjects/MVCFramework.Tests.Serializer.JsonDataObjects.pas @@ -41,7 +41,8 @@ uses MVCFramework.Tests.Serializer.Intf, MVCFramework.Tests.Serializer.Entities, MVCFramework.Tests.Serializer.EntitiesModule, - JsonDataObjects; + JsonDataObjects, + MVCFramework.DataSet.Utils; type @@ -108,7 +109,8 @@ type public procedure SerializeRoot(const AObject: TObject; out ASerializerObject: TObject; - const AAttributes: System.TArray); + const AAttributes: System.TArray; + const ASerializationAction: TMVCSerializationAction = nil); procedure SerializeAttribute(const AElementValue: TValue; const APropertyName: string; const ASerializerObject: TObject; const AAttributes: System.TArray); @@ -134,7 +136,8 @@ type const AAttributes: System.TArray); procedure SerializeRoot(const AObject: TObject; out ASerializerObject: TObject; - const AAttributes: System.TArray); + const AAttributes: System.TArray; + const ASerializationAction: TMVCSerializationAction = nil); end; implementation @@ -288,6 +291,20 @@ const '"Name_Name":"Ezequiel Juliano Müller"' + '}' + ']'; + + JSON_ITEMS= + '{' + + '"items":[' + + '{' + + '"Id_Id":1,' + + '"Name_Name":"Pedro Henrique de Oliveira"' + + '},' + + '{' + + '"Id_Id":2,' + + '"Name_Name":"Rogers Abe"' + + '}' + + '],' + + '"meta":{"count":"2"}}'; var Dm: TEntitiesModule; begin @@ -342,6 +359,16 @@ begin Dm.EntityAsIs.Next; Assert.isTrue(Dm.EntityAsIsId.AsLargeInt = 2); Assert.isTrue(Dm.EntityAsIsName.AsString = 'Ezequiel Juliano Müller'); + + Dm.EntityAsIs.EmptyDataSet; + Dm.EntityAsIs.LoadFromJSONArrayStringItems(JSON_ITEMS); + Dm.EntityAsIs.First; + Assert.isTrue(Dm.EntityAsIsId.AsLargeInt = 1); + Assert.isTrue(Dm.EntityAsIsName.AsString = 'Pedro Henrique de Oliveira'); + + Dm.EntityAsIs.Next; + Assert.isTrue(Dm.EntityAsIsId.AsLargeInt = 2); + Assert.isTrue(Dm.EntityAsIsName.AsString = 'Rogers Abe'); finally Dm.Free; end; @@ -701,6 +728,7 @@ const '"Name_Name":"Ezequiel Juliano Müller"' + '}' + ']'; + var Dm: TEntitiesModule; S: string; @@ -1306,7 +1334,8 @@ end; procedure TMVCEntityCustomSerializerJsonDataObjects.SerializeRoot( const AObject: TObject; out ASerializerObject: TObject; - const AAttributes: System.TArray); + const AAttributes: System.TArray; + const ASerializationAction: TMVCSerializationAction); var lEntityCustom: TEntityCustom; begin @@ -1348,7 +1377,8 @@ end; procedure TMVCNullableIntegerSerializerJsonDataObjects.SerializeRoot( const AObject: TObject; out ASerializerObject: TObject; - const AAttributes: System.TArray); + const AAttributes: System.TArray; + const ASerializationAction: TMVCSerializationAction); begin end;