|
27 | 27 | using System.Diagnostics; |
28 | 28 | using System.IO; |
29 | 29 | using System.Linq; |
| 30 | +#if !WINDOWS_PHONE |
| 31 | +#if !NET35 && !UNITY |
| 32 | +#if !UNITY || MSGPACK_UNITY_FULL |
| 33 | +using System.Numerics; |
| 34 | +#endif // !UNITY || MSGPACK_UNITY_FULL |
| 35 | +#endif // !NET35 && !UNITY |
| 36 | +#endif // !WINDOWS_PHONE |
30 | 37 | using System.Runtime.Serialization; |
| 38 | +#if FEATURE_TAP |
| 39 | +using System.Threading; |
| 40 | +using System.Threading.Tasks; |
| 41 | +#endif // FEATURE_TAP |
31 | 42 | #if !MSTEST |
32 | 43 | using NUnit.Framework; |
33 | 44 | #else |
@@ -462,5 +473,63 @@ public class Issue252Class |
462 | 473 | public byte[] ByteArray = new byte[ MessagePackSerializer.BufferSize - sizeof( int ) - sizeof( byte ) - 1 - 1 ]; |
463 | 474 | public int Int32 = Int32.MaxValue; |
464 | 475 | } |
| 476 | + |
| 477 | + [Test] |
| 478 | + public void TestIssue270_Default() |
| 479 | + { |
| 480 | + var context = new SerializationContext(); |
| 481 | + var guidBytes = context.GetSerializer<Guid>().PackSingleObject( Guid.NewGuid() ); |
| 482 | + Assert.That( guidBytes[ 0 ], Is.EqualTo( MessagePackCode.Bin8 ) ); |
| 483 | +#if !WINDOWS_PHONE |
| 484 | +#if !NET35 && !UNITY |
| 485 | +#if !UNITY || MSGPACK_UNITY_FULL |
| 486 | + var bigIntBytes = context.GetSerializer<BigInteger>().PackSingleObject( new BigInteger( 123 ) ); |
| 487 | + Assert.That( bigIntBytes[ 0 ], Is.EqualTo( MessagePackCode.Bin8 ) ); |
| 488 | +#endif // !UNITY || MSGPACK_UNITY_FULL |
| 489 | +#endif // !NET35 && !UNITY |
| 490 | +#endif // !WINDOWS_PHONE |
| 491 | + } |
| 492 | + |
| 493 | + [Test] |
| 494 | + public void TestIssue270_AsRaw() |
| 495 | + { |
| 496 | + var context = new SerializationContext(); |
| 497 | + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.PackBinaryAsRaw; |
| 498 | + var guidBytes = context.GetSerializer<Guid>().PackSingleObject( Guid.NewGuid() ); |
| 499 | + Assert.That( guidBytes[ 0 ], Is.EqualTo( 0xB0 ) ); |
| 500 | +#if !WINDOWS_PHONE |
| 501 | +#if !NET35 && !UNITY |
| 502 | +#if !UNITY || MSGPACK_UNITY_FULL |
| 503 | + var bigIntBytes = context.GetSerializer<BigInteger>().PackSingleObject( new BigInteger( 123 ) ); |
| 504 | + Assert.That( bigIntBytes[ 0 ], Is.EqualTo( 0xA1 ) ); |
| 505 | +#endif // !UNITY || MSGPACK_UNITY_FULL |
| 506 | +#endif // !NET35 && !UNITY |
| 507 | +#endif // !WINDOWS_PHONE |
| 508 | + } |
| 509 | + |
| 510 | +#if FEATURE_TAP |
| 511 | + |
| 512 | + [Test] |
| 513 | + public async Task TestIssue270Async_Default() |
| 514 | + { |
| 515 | + var context = new SerializationContext(); |
| 516 | + var guidBytes = await context.GetSerializer<Guid>().PackSingleObjectAsync( Guid.NewGuid() ); |
| 517 | + Assert.That( guidBytes[ 0 ], Is.EqualTo( MessagePackCode.Bin8 ) ); |
| 518 | + var bigIntBytes = await context.GetSerializer<BigInteger>().PackSingleObjectAsync( new BigInteger( 123 ) ); |
| 519 | + Assert.That( bigIntBytes[ 0 ], Is.EqualTo( MessagePackCode.Bin8 ) ); |
| 520 | + } |
| 521 | + |
| 522 | + [Test] |
| 523 | + public async Task TestIssue270Async_AsRaw() |
| 524 | + { |
| 525 | + var context = new SerializationContext(); |
| 526 | + context.CompatibilityOptions.PackerCompatibilityOptions = PackerCompatibilityOptions.PackBinaryAsRaw; |
| 527 | + var guidBytes = await context.GetSerializer<Guid>().PackSingleObjectAsync( Guid.NewGuid() ); |
| 528 | + Assert.That( guidBytes[ 0 ], Is.EqualTo( 0xB0 ) ); |
| 529 | + var bigIntBytes = await context.GetSerializer<BigInteger>().PackSingleObjectAsync( new BigInteger( 123 ) ); |
| 530 | + Assert.That( bigIntBytes[ 0 ], Is.EqualTo( 0xA1 ) ); |
| 531 | + } |
| 532 | + |
| 533 | +#endif // FEATURE_TAP |
465 | 534 | } |
466 | 535 | } |
0 commit comments