-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad2f1a4
commit c3d355a
Showing
34 changed files
with
5,111 additions
and
32 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
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RunSettings> | ||
<!-- Configurations that affect the Test Framework --> | ||
<RunConfiguration> | ||
<MaxCpuCount>1</MaxCpuCount> | ||
<ResultsDirectory>.\TestResults</ResultsDirectory><!-- Path relative to solution directory --> | ||
<TestSessionTimeout>120000</TestSessionTimeout><!-- Milliseconds --> | ||
<TargetFrameworkVersion>net48</TargetFrameworkVersion> | ||
<TargetPlatform>x64</TargetPlatform> | ||
</RunConfiguration> | ||
<nanoFrameworkAdapter> | ||
<Logging>None</Logging> | ||
<IsRealHardware>False</IsRealHardware> | ||
</nanoFrameworkAdapter> | ||
</RunSettings> |
File renamed without changes.
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>88d19908-57c1-4b09-9993-de00cee88bf4</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>Serialization.Shared</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)FieldNoReflectionAttribute.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)SerializationHintsAttribute.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)SerializationOptions.cs" /> | ||
</ItemGroup> | ||
</Project> |
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>88d19908-57c1-4b09-9993-de00cee88bf4</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="Serialization.Shared.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
File renamed without changes.
File renamed without changes.
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,109 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using System.Collections; | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
using nanoFramework.TestFramework; | ||
using System; | ||
using BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter; | ||
#else | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using nanoFramework.Serialization.Helper; | ||
#endif | ||
|
||
namespace nanoFramework.System.Runtime.Serialization.Tests | ||
{ | ||
[TestClass] | ||
public class DeserializationTests | ||
{ | ||
[TestMethod] | ||
public void DeserializePersonClassTest() | ||
{ | ||
// serialize person class | ||
var personeOne = UnitTestHelper.CreatePersonOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var newPersoneOne = BinaryFormatter.Deserialize(UnitTestHelper.PersonOneSerialized) as Person; | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var newPersoneOne = binaryFormatter.Deserialize(UnitTestHelper.PersonOneSerialized) as Person; | ||
#endif | ||
|
||
Assert.IsNotNull(newPersoneOne); | ||
Assert.AreEqual(newPersoneOne.LastName, personeOne.LastName); | ||
Assert.AreEqual(newPersoneOne.FirstName, personeOne.FirstName); | ||
Assert.AreEqual(newPersoneOne.ID, personeOne.ID); | ||
Assert.AreEqual(newPersoneOne.Address, personeOne.Address); | ||
Assert.AreEqual(newPersoneOne.Birthday, personeOne.Birthday); | ||
Assert.AreEqual(newPersoneOne.Friend.LastName, personeOne.Friend.LastName); | ||
Assert.AreEqual(newPersoneOne.Friend.FirstName, personeOne.Friend.FirstName); | ||
Assert.AreEqual(newPersoneOne.Friend.ID, personeOne.Friend.ID); | ||
Assert.AreEqual(newPersoneOne.Friend.Address, personeOne.Friend.Address); | ||
Assert.AreEqual(newPersoneOne.Friend.Birthday, personeOne.Friend.Birthday); | ||
} | ||
|
||
[TestMethod] | ||
public void DeserializeComplexClassTest() | ||
{ | ||
// serialize Complex class | ||
var complexeClassOne = UnitTestHelper.CreateComplexClassOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var newComplexeClassOne = BinaryFormatter.Deserialize(UnitTestHelper.ComplexClassOneSerialized) as ComplexClass; | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var newComplexeClassOne = binaryFormatter.Deserialize(UnitTestHelper.ComplexClassOneSerialized) as ComplexClass; | ||
#endif | ||
|
||
Assert.IsNotNull(newComplexeClassOne); | ||
Assert.AreEqual(newComplexeClassOne.aInteger, complexeClassOne.aInteger); | ||
Assert.AreEqual(newComplexeClassOne.aShort, complexeClassOne.aShort); | ||
Assert.AreEqual(newComplexeClassOne.aByte, complexeClassOne.aByte); | ||
Assert.AreEqual(newComplexeClassOne.aString, complexeClassOne.aString); | ||
Assert.AreEqual(newComplexeClassOne.aFloat, complexeClassOne.aFloat); | ||
Assert.AreEqual(newComplexeClassOne.aDouble, complexeClassOne.aDouble); | ||
Assert.AreEqual(newComplexeClassOne.aBoolean, complexeClassOne.aBoolean); | ||
Assert.AreEqual(newComplexeClassOne.Timestamp, complexeClassOne.Timestamp); | ||
Assert.AreEqual(newComplexeClassOne.FixedTimestamp, complexeClassOne.FixedTimestamp); | ||
Assert.AreEqual(newComplexeClassOne.nullObject, complexeClassOne.nullObject); | ||
Assert.AreEqual(newComplexeClassOne.nanFloat, complexeClassOne.nanFloat); | ||
Assert.AreEqual(newComplexeClassOne.nanDouble, complexeClassOne.nanDouble); | ||
|
||
CollectionAssert.AreEqual(newComplexeClassOne.intArray, complexeClassOne.intArray); | ||
CollectionAssert.AreEqual(newComplexeClassOne.shortArray, complexeClassOne.shortArray); | ||
CollectionAssert.AreEqual(newComplexeClassOne.byteArray, complexeClassOne.byteArray); | ||
CollectionAssert.AreEqual(newComplexeClassOne.stringArray, complexeClassOne.stringArray); | ||
CollectionAssert.AreEqual(newComplexeClassOne.floatArray, complexeClassOne.floatArray); | ||
CollectionAssert.AreEqual(newComplexeClassOne.doubleArray, complexeClassOne.doubleArray); | ||
|
||
Assert.AreEqual(newComplexeClassOne.Child.one, complexeClassOne.Child.one); | ||
Assert.AreEqual(newComplexeClassOne.Child.two, complexeClassOne.Child.two); | ||
Assert.AreEqual(newComplexeClassOne.Child.three, complexeClassOne.Child.three); | ||
|
||
Assert.AreEqual(newComplexeClassOne.child1.one, complexeClassOne.child1.one); | ||
Assert.AreEqual(newComplexeClassOne.child1.two, complexeClassOne.child1.two); | ||
Assert.AreEqual(newComplexeClassOne.child1.three, complexeClassOne.child1.three); | ||
} | ||
|
||
[TestMethod] | ||
public void DeserializeArrayListTest() | ||
{ | ||
// serialize array list | ||
var personeOne = UnitTestHelper.CreateArrayListOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var newArrayListeOne = BinaryFormatter.Deserialize(UnitTestHelper.ArrayListOneSerialized) as ArrayList; | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var newArrayListeOne = binaryFormatter.Deserialize(UnitTestHelper.ArrayListOneSerialized) as ArrayList; | ||
#endif | ||
|
||
Assert.IsNotNull(newArrayListeOne); | ||
CollectionAssert.AreEqual(newArrayListeOne, personeOne); | ||
} | ||
} | ||
} |
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,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> | ||
<RestoreLockedMode Condition="'$(TF_BUILD)' == 'True' or '$(ContinuousIntegrationBuild)' == 'True'">true</RestoreLockedMode> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\nanoFramework.Serialization.Helper\nanoFramework.Serialization.Helper.csproj" /> | ||
</ItemGroup> | ||
|
||
<Import Project="..\UnitTests.Shared\UnitTests.Shared.projitems" Label="Shared" /> | ||
|
||
<Import Project="..\..\Serialization.Shared\Serialization.Shared.projitems" Label="Shared" /> | ||
|
||
</Project> |
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,77 @@ | ||
// | ||
// Copyright (c) .NET Foundation and Contributors | ||
// Portions Copyright (c) Microsoft Corporation. All rights reserved. | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
using nanoFramework.TestFramework; | ||
using BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter; | ||
#else | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using nanoFramework.Serialization.Helper; | ||
#endif | ||
|
||
namespace nanoFramework.System.Runtime.Serialization.Tests | ||
{ | ||
[TestClass] | ||
public class SerializationTests | ||
{ | ||
[TestMethod] | ||
public void SerializePersonClassTest() | ||
{ | ||
// serialize person class | ||
var personeOne = UnitTestHelper.CreatePersonOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var serializedPerson = BinaryFormatter.Serialize(personeOne); | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var serializedPerson = binaryFormatter.Serialize(personeOne); | ||
#endif | ||
|
||
Assert.IsNotNull(serializedPerson); | ||
Assert.IsTrue(serializedPerson.Length == UnitTestHelper.PersonOneSerialized.Length, "PersonOne serialized data has different length."); | ||
|
||
CollectionAssert.AreEqual(UnitTestHelper.PersonOneSerialized, serializedPerson); | ||
} | ||
|
||
[TestMethod] | ||
public void SerializeComplexClassTest() | ||
{ | ||
// serialize complex class | ||
var complexClassOne = UnitTestHelper.CreateComplexClassOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var serializedComplexClass = BinaryFormatter.Serialize(complexClassOne); | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var serializedComplexClass = binaryFormatter.Serialize(complexClassOne); | ||
#endif | ||
|
||
Assert.IsNotNull(serializedComplexClass); | ||
Assert.IsTrue(serializedComplexClass.Length == UnitTestHelper.ComplexClassOneSerialized.Length, "ComplexClass serialized data has different length."); | ||
|
||
CollectionAssert.AreEqual(UnitTestHelper.ComplexClassOneSerialized, serializedComplexClass); | ||
} | ||
|
||
[TestMethod] | ||
public void SerializeArrayListTest() | ||
{ | ||
// serialize array list | ||
var arrayListOne = UnitTestHelper.CreateArrayListOne(); | ||
|
||
#if NANOFRAMEWORK_1_0 | ||
var serializedArrayList = BinaryFormatter.Serialize(arrayListOne); | ||
#else | ||
var binaryFormatter = new BinaryFormatter(); | ||
var serializedArrayList = binaryFormatter.Serialize(arrayListOne); | ||
#endif | ||
|
||
Assert.IsNotNull(serializedArrayList); | ||
Assert.IsTrue(serializedArrayList.Length == UnitTestHelper.ArrayListOneSerialized.Length, "ArrayListOne serialized data has different length."); | ||
|
||
CollectionAssert.AreEqual(UnitTestHelper.ArrayListOneSerialized, serializedArrayList); | ||
} | ||
} | ||
} |
Oops, something went wrong.