-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from BetimBeja/feature/improve-coverage
Improved coverage.
- Loading branch information
Showing
8 changed files
with
230 additions
and
6 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
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,40 @@ | ||
using Microsoft.Xrm.Sdk; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace XrmEntitySerializer.Tests | ||
{ | ||
public class ParameterCollectionTests | ||
{ | ||
[Fact] | ||
public void ParameterCollectionCanBeSerializedAndDeserialized() | ||
{ | ||
ParameterCollection parameterCollection = new ParameterCollection(); | ||
parameterCollection.Add("Entity", new Entity("account")); | ||
parameterCollection.Add("EntityReference", new EntityReference("contact", Guid.NewGuid())); | ||
|
||
EntitySerializer serializer = new EntitySerializer(); | ||
serializer.TypeNameHandling = TypeNameHandling.Objects; | ||
MemoryStream memoryStream = new MemoryStream(new byte[9000], true); | ||
|
||
using (StreamWriter writer = new StreamWriter(memoryStream)) | ||
{ | ||
serializer.Serialize(new JsonTextWriter(writer), parameterCollection); | ||
} | ||
|
||
ParameterCollection deserializedParameterCollection; | ||
memoryStream = new MemoryStream(memoryStream.ToArray()); | ||
using (StreamReader reader = new StreamReader(memoryStream)) | ||
{ | ||
deserializedParameterCollection = (ParameterCollection)serializer.Deserialize(new JsonTextReader(reader), typeof(ParameterCollection)); | ||
} | ||
|
||
Assert.Equal(parameterCollection.GetType(), deserializedParameterCollection.GetType()); | ||
Assert.Equal(parameterCollection.Count, deserializedParameterCollection.Count); | ||
Assert.Equal(parameterCollection.Keys.First(), deserializedParameterCollection.Keys.First()); | ||
} | ||
} | ||
} |
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
162 changes: 162 additions & 0 deletions
162
XrmEntitySerializer.Tests/SampleData/RemoteExecutionContext.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,162 @@ | ||
{ | ||
"BusinessUnitId": "f0bf3c9a-8150-e811-a953-000d3af29fc0", | ||
"CorrelationId": "39499111-e689-42a1-ae8a-5b14a84514ce", | ||
"Depth": 1, | ||
"InitiatingUserId": "df010dad-f103-4589-ba66-76a5a04c2a11", | ||
"InputParameters": [ | ||
{ | ||
"key": "Target", | ||
"value": { | ||
"__type": "Entity:http:\/\/schemas.microsoft.com\/xrm\/2011\/Contracts", | ||
"Attributes": [ | ||
{ | ||
"key": "telephone1", | ||
"value": "1111" | ||
}, | ||
{ | ||
"key": "accountid", | ||
"value": "ec4e2f7d-9d60-e811-a95a-000d3af24950" | ||
}, | ||
{ | ||
"key": "modifiedon", | ||
"value": "\/Date(1527757524000)\/" | ||
}, | ||
{ | ||
"key": "modifiedby", | ||
"value": { | ||
"__type": "EntityReference:http:\/\/schemas.microsoft.com\/xrm\/2011\/Contracts", | ||
"Id": "df010dad-f103-4589-ba66-76a5a04c2a11", | ||
"KeyAttributes": [], | ||
"LogicalName": "systemuser", | ||
"Name": null, | ||
"RowVersion": null | ||
} | ||
}, | ||
{ | ||
"key": "modifiedonbehalfby", | ||
"value": null | ||
} | ||
], | ||
"EntityState": null, | ||
"FormattedValues": [], | ||
"Id": "ec4e2f7d-9d60-e811-a95a-000d3af24950", | ||
"KeyAttributes": [], | ||
"LogicalName": "account", | ||
"RelatedEntities": [], | ||
"RowVersion": null | ||
} | ||
}, | ||
{ | ||
"key": "TargetReference", | ||
"value": { | ||
"__type": "EntityReference:http:\/\/schemas.microsoft.com\/xrm\/2011\/Contracts", | ||
"Id": "df010dad-f103-4589-ba66-76a5a04c2a11", | ||
"KeyAttributes": [], | ||
"LogicalName": "systemuser", | ||
"Name": null, | ||
"RowVersion": null | ||
} | ||
} | ||
], | ||
"IsExecutingOffline": false, | ||
"IsInTransaction": true, | ||
"IsOfflinePlayback": false, | ||
"IsolationMode": 1, | ||
"MessageName": "Update", | ||
"Mode": 0, | ||
"OperationCreatedOn": "\/Date(1527757530151)\/", | ||
"OperationId": "08fec203-ec78-4f7a-a024-c96e329a64fe", | ||
"OrganizationId": "b0714265-8e72-4d3b-8239-ecf0970a3da6", | ||
"OrganizationName": "org94971a24", | ||
"OutputParameters": [], | ||
"OwningExtension": { | ||
"Id": "3db800fe-0963-e811-a95a-000d3af24324", | ||
"KeyAttributes": [], | ||
"LogicalName": "sdkmessageprocessingstep", | ||
"Name": "D365WebHookHttpTrigger: Update of account", | ||
"RowVersion": null | ||
}, | ||
"ParentContext": { | ||
"BusinessUnitId": "f0bf3c9a-8150-e811-a953-000d3af29fc0", | ||
"CorrelationId": "39499111-e689-42a1-ae8a-5b14a84514ce", | ||
"Depth": 1, | ||
"InitiatingUserId": "df010dad-f103-4589-ba66-76a5a04c2a11", | ||
"InputParameters": [ | ||
{ | ||
"key": "Target", | ||
"value": { | ||
"__type": "Entity:http:\/\/schemas.microsoft.com\/xrm\/2011\/Contracts", | ||
"Attributes": [ | ||
{ | ||
"key": "telephone1", | ||
"value": "1111" | ||
}, | ||
{ | ||
"key": "accountid", | ||
"value": "ec4e2f7d-9d60-e811-a95a-000d3af24950" | ||
} | ||
], | ||
"EntityState": null, | ||
"FormattedValues": [], | ||
"Id": "ec4e2f7d-9d60-e811-a95a-000d3af24950", | ||
"KeyAttributes": [], | ||
"LogicalName": "account", | ||
"RelatedEntities": [], | ||
"RowVersion": null | ||
} | ||
}, | ||
{ | ||
"key": "SuppressDuplicateDetection", | ||
"value": false | ||
} | ||
], | ||
"IsExecutingOffline": false, | ||
"IsInTransaction": true, | ||
"IsOfflinePlayback": false, | ||
"IsolationMode": 1, | ||
"MessageName": "Update", | ||
"Mode": 0, | ||
"OperationCreatedOn": "\/Date(1527757524631)\/", | ||
"OperationId": "08fec203-ec78-4f7a-a024-c96e329a64fe", | ||
"OrganizationId": "b0714265-8e72-4d3b-8239-ecf0970a3da6", | ||
"OrganizationName": "org94971a24", | ||
"OutputParameters": [], | ||
"OwningExtension": { | ||
"Id": "63cdbb1b-ea3e-db11-86a7-000a3a5473e8", | ||
"KeyAttributes": [], | ||
"LogicalName": "sdkmessageprocessingstep", | ||
"Name": "ObjectModel Implementation", | ||
"RowVersion": null | ||
}, | ||
"ParentContext": null, | ||
"PostEntityImages": [], | ||
"PreEntityImages": [], | ||
"PrimaryEntityId": "ec4e2f7d-9d60-e811-a95a-000d3af24950", | ||
"PrimaryEntityName": "account", | ||
"RequestId": "08fec203-ec78-4f7a-a024-c96e329a64fe", | ||
"SecondaryEntityName": "none", | ||
"SharedVariables": [ | ||
{ | ||
"key": "ChangedEntityTypes", | ||
"value": [ | ||
{ | ||
"__type": "KeyValuePairOfstringstring:#System.Collections.Generic", | ||
"key": "account", | ||
"value": "Update" | ||
} | ||
] | ||
} | ||
], | ||
"Stage": 30, | ||
"UserId": "df010dad-f103-4589-ba66-76a5a04c2a11" | ||
}, | ||
"PostEntityImages": [], | ||
"PreEntityImages": [], | ||
"PrimaryEntityId": "ec4e2f7d-9d60-e811-a95a-000d3af24950", | ||
"PrimaryEntityName": "account", | ||
"RequestId": "08fec203-ec78-4f7a-a024-c96e329a64fe", | ||
"SecondaryEntityName": "none", | ||
"SharedVariables": [], | ||
"Stage": 40, | ||
"UserId": "df010dad-f103-4589-ba66-76a5a04c2a11" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
& .\coverage.ps1 | ||
|
||
IF(!(Test-Path .coverage\ReportGenerator* -PathType Container)) | ||
{ | ||
& nuget install ReportGenerator -OutputDirectory .coverage | ||
} | ||
|
||
$ReportGenerator=Get-ChildItem -Path $((Get-ChildItem -Path .coverage\ReportGenerator* | Sort-Object -Descending | Select-Object -First 1).FullName)tools\net47\ReportGenerator.exe | ||
|
||
If($ReportGenerator -eq ''){ | ||
throw "Could not find ReportGenerator. Make sure to restore NuGet packages" | ||
} | ||
|
||
& $ReportGenerator -reports:".coverage\XrmEntitySerializer.5.net40.xml;.coverage\XrmEntitySerializer.6.net40.xml;.coverage\XrmEntitySerializer.7.net452.xml;.coverage\XrmEntitySerializer.8.net452.xml;.coverage\XrmEntitySerializer.9.net452.xml;.coverage\XrmEntitySerializer.9.net462.xml;.coverage\XrmEntitySerializer.core.net5.0.xml;.coverage\XrmEntitySerializer.core.netcoreapp3.0.xml;.coverage\XrmEntitySerializer.core.netcoreapp3.1.xml" -targetdir:".coverage\report" -reporttypes:"html" | ||
|
||
Start-Process .coverage\report\index.htm |
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