-
Notifications
You must be signed in to change notification settings - Fork 335
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 #95 from satano/94-InvalidCastException
Object to primitive type is always converted using Convert class. Fixes #94
- Loading branch information
Showing
3 changed files
with
75 additions
and
41 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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace Mapster.Tests | ||
{ | ||
[TestFixture] | ||
class WhenConvertingFromObjects | ||
{ | ||
|
||
#region TestClasses | ||
|
||
public class SimplePoco | ||
{ | ||
public int Int32 { get; set; } | ||
public long Int64 { get; set; } | ||
} | ||
|
||
#endregion | ||
|
||
[Test] | ||
public void Int32_In_Object_Is_Converted_To_Int64() | ||
{ | ||
var dictionaryData = new Dictionary<string, object> | ||
{ | ||
{ "Int32", 32 }, | ||
{ "Int64", 64 } | ||
}; | ||
|
||
var poco = dictionaryData.Adapt<SimplePoco>(); | ||
poco.Int32.ShouldBe(32); | ||
poco.Int64.ShouldBe(64L); | ||
} | ||
} | ||
} |
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