-Build
-Tests
This commit is contained in:
+2
-2
@@ -52,8 +52,8 @@ task Merge -depends Build {
|
|||||||
del $binaryDir\LinqBridge.dll
|
del $binaryDir\LinqBridge.dll
|
||||||
|
|
||||||
$binaryDir = "$sourceDir\Newtonsoft.Json.Tests\bin\Release\DotNet20"
|
$binaryDir = "$sourceDir\Newtonsoft.Json.Tests\bin\Release\DotNet20"
|
||||||
MergeAssembly "$binaryDir\Newtonsoft.Json.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
|
||||||
MergeAssembly "$binaryDir\Newtonsoft.Json.Tests.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
MergeAssembly "$binaryDir\Newtonsoft.Json.Tests.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
||||||
|
MergeAssembly "$binaryDir\Newtonsoft.Json.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
||||||
del $binaryDir\LinqBridge.dll
|
del $binaryDir\LinqBridge.dll
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ function MergeAssembly($dllPrimaryAssembly, $signKey, [string[]]$mergedAssemlies
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
exec { .\Tools\ILMerge\ilmerge.exe "/internalize" $ilMergeKeyFile "/out:$temporaryDir\$mergedAssemblyName" $dllPrimaryAssembly $mergeAssemblyPaths } "Error executing ILMerge"
|
exec { .\Tools\ILMerge\ilmerge.exe "/internalize" "/closed" "/log" $ilMergeKeyFile "/out:$temporaryDir\$mergedAssemblyName" $dllPrimaryAssembly $mergeAssemblyPaths } "Error executing ILMerge"
|
||||||
Copy-Item -Path $temporaryDir\$mergedAssemblyName -Destination $dllPrimaryAssembly -Force
|
Copy-Item -Path $temporaryDir\$mergedAssemblyName -Destination $dllPrimaryAssembly -Force
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -198,6 +198,7 @@
|
|||||||
<Compile Include="TestObjects\UserNullable.cs" />
|
<Compile Include="TestObjects\UserNullable.cs" />
|
||||||
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
||||||
<Compile Include="TestObjects\WagePerson.cs" />
|
<Compile Include="TestObjects\WagePerson.cs" />
|
||||||
|
<Compile Include="Utilities\LateBoundDelegateFactoryTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Compact.csproj">
|
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Compact.csproj">
|
||||||
|
|||||||
@@ -204,6 +204,7 @@
|
|||||||
<Compile Include="TestObjects\UserNullable.cs" />
|
<Compile Include="TestObjects\UserNullable.cs" />
|
||||||
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
||||||
<Compile Include="TestObjects\WagePerson.cs" />
|
<Compile Include="TestObjects\WagePerson.cs" />
|
||||||
|
<Compile Include="Utilities\LateBoundDelegateFactoryTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
|
<Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
|
||||||
|
|||||||
@@ -209,6 +209,7 @@
|
|||||||
<Compile Include="TestObjects\UserNullable.cs" />
|
<Compile Include="TestObjects\UserNullable.cs" />
|
||||||
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
||||||
<Compile Include="TestObjects\WagePerson.cs" />
|
<Compile Include="TestObjects\WagePerson.cs" />
|
||||||
|
<Compile Include="Utilities\LateBoundDelegateFactoryTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Silverlight.csproj">
|
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.Silverlight.csproj">
|
||||||
|
|||||||
@@ -244,6 +244,7 @@
|
|||||||
<Compile Include="TestObjects\TypeClass.cs" />
|
<Compile Include="TestObjects\TypeClass.cs" />
|
||||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||||
<Compile Include="TestObjects\UserNullable.cs" />
|
<Compile Include="TestObjects\UserNullable.cs" />
|
||||||
|
<Compile Include="Utilities\LateBoundDelegateFactoryTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.csproj">
|
<ProjectReference Include="..\Newtonsoft.Json\Newtonsoft.Json.csproj">
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#region License
|
||||||
|
// Copyright (c) 2007 James Newton-King
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person
|
||||||
|
// obtaining a copy of this software and associated documentation
|
||||||
|
// files (the "Software"), to deal in the Software without
|
||||||
|
// restriction, including without limitation the rights to use,
|
||||||
|
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following
|
||||||
|
// conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be
|
||||||
|
// included in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
// OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#if !PocketPC && !SILVERLIGHT
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Newtonsoft.Json.Utilities;
|
||||||
|
using Newtonsoft.Json.Tests.TestObjects;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Utilities
|
||||||
|
{
|
||||||
|
public class LateBoundDelegateFactoryTests : TestFixtureBase
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(InvalidCastException), ExpectedMessage = "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.")]
|
||||||
|
public void CreateGetWithBadObjectTarget()
|
||||||
|
{
|
||||||
|
Person p = new Person();
|
||||||
|
p.Name = "Hi";
|
||||||
|
|
||||||
|
Func<object, object> setter = LateBoundDelegateFactory.CreateGet<object>(typeof(Movie).GetProperty("Name"));
|
||||||
|
|
||||||
|
setter(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(InvalidCastException), ExpectedMessage = "Unable to cast object of type 'Newtonsoft.Json.Tests.TestObjects.Person' to type 'Newtonsoft.Json.Tests.TestObjects.Movie'.")]
|
||||||
|
public void CreateSetWithBadObjectTarget()
|
||||||
|
{
|
||||||
|
Person p = new Person();
|
||||||
|
Movie m = new Movie();
|
||||||
|
|
||||||
|
Action<object, object> setter = LateBoundDelegateFactory.CreateSet<object>(typeof(Movie).GetProperty("Name"));
|
||||||
|
|
||||||
|
setter(m, "Hi");
|
||||||
|
|
||||||
|
Assert.AreEqual(m.Name, "Hi");
|
||||||
|
|
||||||
|
setter(p, "Hi");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(InvalidCastException), ExpectedMessage = "Specified cast is not valid.")]
|
||||||
|
public void CreateSetWithBadTarget()
|
||||||
|
{
|
||||||
|
object structTest = new StructTest();
|
||||||
|
|
||||||
|
Action<object, object> setter = LateBoundDelegateFactory.CreateSet<object>(typeof(StructTest).GetProperty("StringProperty"));
|
||||||
|
|
||||||
|
setter(structTest, "Hi");
|
||||||
|
|
||||||
|
Assert.AreEqual("Hi", ((StructTest)structTest).StringProperty);
|
||||||
|
|
||||||
|
setter(new TimeSpan(), "Hi");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(InvalidCastException), ExpectedMessage = "Unable to cast object of type 'System.Version' to type 'System.String'.")]
|
||||||
|
public void CreateSetWithBadObjectValue()
|
||||||
|
{
|
||||||
|
Movie m = new Movie();
|
||||||
|
|
||||||
|
Action<object, object> setter = LateBoundDelegateFactory.CreateSet<object>(typeof(Movie).GetProperty("Name"));
|
||||||
|
|
||||||
|
setter(m, new Version());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user