-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use same unit JsoinSerializer tests for Net and NetCore - Add extra datamodel version checks to JsonSerializers
- Loading branch information
Alexander van Delft
committed
Nov 27, 2024
1 parent
53eb823
commit 64abba5
Showing
153 changed files
with
3,123 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
CDP4JsonSerializer.NetCore.Tests/PostOperation/CreateDerivedQuantityKindPostMessage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"_delete": [], | ||
"_create": [ | ||
{ | ||
"alias": [], | ||
"category": [], | ||
"classKind": "DerivedQuantityKind", | ||
"defaultScale": "56863161-fa3a-47b8-a3cd-16465f734b27", | ||
"definition": [], | ||
"excludedDomain": [], | ||
"excludedPerson": [], | ||
"hyperLink": [], | ||
"iid": "08c130ca-a270-408f-8069-b7e1d00659f0", | ||
"isDeprecated": false, | ||
"modifiedOn": "2018-08-12T14:10:55.560Z", | ||
"name": "derivedQuantityKind", | ||
"possibleScale": [ "56863161-fa3a-47b8-a3cd-16465f734b27" ], | ||
"quantityDimensionSymbol": "dqk", | ||
"quantityKindFactor": [ | ||
{ | ||
"k": -12551680, | ||
"v": "11aa4db6-40ef-4368-92ac-bda8af9b27a9" | ||
}, | ||
{ | ||
"k": 77606679, | ||
"v": "125abfbd-f717-42c0-91da-738316159ea5" | ||
} | ||
], | ||
"revisionNumber": 0, | ||
"shortName": "derivedQuantityKind", | ||
"symbol": "derivedQuantityKind" | ||
}, | ||
{ | ||
"classKind": "QuantityKindFactor", | ||
"excludedDomain": [], | ||
"excludedPerson": [], | ||
"exponent": "1", | ||
"iid": "11aa4db6-40ef-4368-92ac-bda8af9b27a9", | ||
"modifiedOn": "2018-08-12T14:10:45.476Z", | ||
"quantityKind": "9513aca9-5397-48a1-8187-1683490bdb4f", | ||
"revisionNumber": 0 | ||
}, | ||
{ | ||
"classKind": "QuantityKindFactor", | ||
"excludedDomain": [], | ||
"excludedPerson": [], | ||
"exponent": "2", | ||
"iid": "125abfbd-f717-42c0-91da-738316159ea5", | ||
"modifiedOn": "2018-08-12T14:10:50.681Z", | ||
"quantityKind": "1c53f8f4-024b-4f42-987a-439901a4bcb2", | ||
"revisionNumber": 0 | ||
} | ||
], | ||
"_update": [ | ||
{ | ||
"classKind": "SiteReferenceDataLibrary", | ||
"iid": "bff9f871-3b7f-4e57-ac82-5ab499f9baf5", | ||
"parameterType": [ "08c130ca-a270-408f-8069-b7e1d00659f0" ] | ||
} | ||
], | ||
"_copy": [] | ||
} |
106 changes: 106 additions & 0 deletions
106
CDP4JsonSerializer.NetCore.Tests/PostOperation/JsonSerializerPostOperationTestFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="JsonSerializerPostOperationTestFixture.cs" company="Starion Group S.A."> | ||
// Copyright (c) 2015-2024 Starion Group S.A. | ||
// | ||
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou | ||
// | ||
// This file is part of CDP4-COMET SDK Community Edition | ||
// | ||
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 3 of the License, or (at your option) any later version. | ||
// | ||
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with this program; if not, write to the Free Software Foundation, | ||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace CDP4JsonSerializer.NetCore.Tests.PostOperation | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using CDP4Common.DTO; | ||
using CDP4Common.MetaInfo; | ||
using CDP4Common.Types; | ||
|
||
using CDP4DalCommon.Protocol.Operations; | ||
|
||
using NUnit.Framework; | ||
|
||
/// <summary> | ||
/// Suite of tests to verify that PostOperation deserialization works as expected | ||
/// </summary> | ||
[TestFixture] | ||
public class JsonSerializerPostOperationTestFixture | ||
{ | ||
private IMetaDataProvider metaDataProvider; | ||
|
||
private Version supportedVersion; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.metaDataProvider = new MetaDataProvider(); | ||
this.supportedVersion = new Version(1,1,0); | ||
} | ||
|
||
[Test] | ||
public void Verify_that_post_message_with_move_keys_can_be_deserialized() | ||
{ | ||
var postMessage = System.IO.File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json")); | ||
var byteArray = Encoding.UTF8.GetBytes(postMessage); | ||
var stream = new MemoryStream(byteArray); | ||
|
||
var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false); | ||
|
||
var cdpPostOperation = cdp4JsonSerializer.Deserialize<PostOperation>(stream); | ||
|
||
Assert.That(cdpPostOperation.Create, Is.Empty); | ||
Assert.That(cdpPostOperation.Delete, Is.Empty); | ||
Assert.That(cdpPostOperation.Copy, Is.Empty); | ||
|
||
var classlessDto = cdpPostOperation.Update.First(); | ||
|
||
var orderedItems = classlessDto["QuantityKindFactor"] as IEnumerable<OrderedItem>; | ||
|
||
var orderedItem_1 = orderedItems.First(); | ||
orderedItem_1.M = 77606679; | ||
|
||
var orderedItem_2 = orderedItems.Last(); | ||
orderedItem_2.M = -12551680; | ||
} | ||
|
||
[Test] | ||
public void Verify_that_post_message_can_be_deserialized() | ||
{ | ||
var postMessage = System.IO.File.ReadAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "PostOperation/CreateDerivedQuantityKindPostMessage.json")); | ||
var byteArray = Encoding.UTF8.GetBytes(postMessage); | ||
var stream = new MemoryStream(byteArray); | ||
|
||
var cdp4JsonSerializer = new Cdp4DalJsonSerializer(this.metaDataProvider, this.supportedVersion, false); | ||
|
||
var cdpPostOperation = cdp4JsonSerializer.Deserialize<PostOperation>(stream); | ||
|
||
Assert.That(cdpPostOperation.Delete, Is.Empty); | ||
Assert.That(cdpPostOperation.Copy, Is.Empty); | ||
|
||
var derivedQuantityKind = cdpPostOperation.Create.First() as DerivedQuantityKind; | ||
var qkf_1 = derivedQuantityKind.QuantityKindFactor.Single(x => x.K == -12551680); | ||
|
||
Assert.That(qkf_1.V, Is.Not.Null); | ||
|
||
Assert.That(qkf_1.M, Is.Null); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...Serializer.NetCore.Tests/PostOperation/ReOderFactorsOfDerivedQuantityKindPostMessage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"_delete": [], | ||
"_create": [], | ||
"_update": [ | ||
{ | ||
"classKind": "DerivedQuantityKind", | ||
"iid": "08c130ca-a270-408f-8069-b7e1d00659f0", | ||
"modifiedOn": "2018-08-12T14:11:56.580Z", | ||
"quantityKindFactor": [ | ||
{ | ||
"k": -12551680, | ||
"m": 77606679, | ||
"v": "11aa4db6-40ef-4368-92ac-bda8af9b27a9" | ||
}, | ||
{ | ||
"k": 77606679, | ||
"m": -12551680, | ||
"v": "125abfbd-f717-42c0-91da-738316159ea5" | ||
} | ||
] | ||
} | ||
], | ||
"_copy": [] | ||
} |
50 changes: 0 additions & 50 deletions
50
CDP4JsonSerializer.Tests/PostOperation/CdpPostOperation.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.