|
32 | 32 | using MsgPack.Serialization.CodeDomSerializers; |
33 | 33 | using MsgPack.Serialization.EmittingSerializers; |
34 | 34 | #endif // SILVERLIGHT && !NETSTANDARD1_1 && !NETSTANDARD1_3 |
| 35 | +#if !NETFX_CORE |
| 36 | +using Microsoft.FSharp.Collections; |
| 37 | +#endif // !NETFX_CORE |
35 | 38 | #if !MSTEST |
36 | 39 | using NUnit.Framework; |
37 | 40 | #else |
@@ -555,5 +558,155 @@ public void ImmutableSortedDictionaryTest_2_Success() |
555 | 558 | Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
556 | 559 | } |
557 | 560 | } |
| 561 | + |
| 562 | +#if !NETFX_CORE |
| 563 | + |
| 564 | + |
| 565 | + [Test] |
| 566 | + public void FSharpListTest_0_Success() |
| 567 | + { |
| 568 | + var collection = FSharpList<int>.Empty; |
| 569 | + var target = this.CreateTarget<FSharpList<int>>(); |
| 570 | + using ( var buffer = new MemoryStream() ) |
| 571 | + { |
| 572 | + target.Pack( buffer, collection ); |
| 573 | + buffer.Position = 0; |
| 574 | + var unpacked = target.Unpack( buffer ); |
| 575 | + buffer.Position = 0; |
| 576 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 577 | + } |
| 578 | + } |
| 579 | + |
| 580 | + [Test] |
| 581 | + public void FSharpListTest_1_Success() |
| 582 | + { |
| 583 | + var collection = FSharpList<int>.Empty; |
| 584 | + collection = new FSharpList<int>( 0, collection ); |
| 585 | + var target = this.CreateTarget<FSharpList<int>>(); |
| 586 | + using ( var buffer = new MemoryStream() ) |
| 587 | + { |
| 588 | + target.Pack( buffer, collection ); |
| 589 | + buffer.Position = 0; |
| 590 | + var unpacked = target.Unpack( buffer ); |
| 591 | + buffer.Position = 0; |
| 592 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 593 | + } |
| 594 | + } |
| 595 | + |
| 596 | + [Test] |
| 597 | + public void FSharpListTest_2_Success() |
| 598 | + { |
| 599 | + var collection = FSharpList<int>.Empty; |
| 600 | + collection = new FSharpList<int>( 0, collection ); |
| 601 | + collection = new FSharpList<int>( 1, collection ); |
| 602 | + var target = this.CreateTarget<FSharpList<int>>(); |
| 603 | + using ( var buffer = new MemoryStream() ) |
| 604 | + { |
| 605 | + target.Pack( buffer, collection ); |
| 606 | + buffer.Position = 0; |
| 607 | + var unpacked = target.Unpack( buffer ); |
| 608 | + buffer.Position = 0; |
| 609 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 610 | + } |
| 611 | + } |
| 612 | + |
| 613 | + [Test] |
| 614 | + public void FSharpSetTest_0_Success() |
| 615 | + { |
| 616 | + var collection = new FSharpSet<int>( Enumerable.Empty<int>() ); |
| 617 | + var target = this.CreateTarget<FSharpSet<int>>(); |
| 618 | + using ( var buffer = new MemoryStream() ) |
| 619 | + { |
| 620 | + target.Pack( buffer, collection ); |
| 621 | + buffer.Position = 0; |
| 622 | + var unpacked = target.Unpack( buffer ); |
| 623 | + buffer.Position = 0; |
| 624 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 625 | + } |
| 626 | + } |
| 627 | + |
| 628 | + [Test] |
| 629 | + public void FSharpSetTest_1_Success() |
| 630 | + { |
| 631 | + var collection = new FSharpSet<int>( Enumerable.Empty<int>() ); |
| 632 | + collection = collection.Add( 0 ); |
| 633 | + var target = this.CreateTarget<FSharpSet<int>>(); |
| 634 | + using ( var buffer = new MemoryStream() ) |
| 635 | + { |
| 636 | + target.Pack( buffer, collection ); |
| 637 | + buffer.Position = 0; |
| 638 | + var unpacked = target.Unpack( buffer ); |
| 639 | + buffer.Position = 0; |
| 640 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 641 | + } |
| 642 | + } |
| 643 | + |
| 644 | + [Test] |
| 645 | + public void FSharpSetTest_2_Success() |
| 646 | + { |
| 647 | + var collection = new FSharpSet<int>( Enumerable.Empty<int>() ); |
| 648 | + collection = collection.Add( 0 ); |
| 649 | + collection = collection.Add( 1 ); |
| 650 | + var target = this.CreateTarget<FSharpSet<int>>(); |
| 651 | + using ( var buffer = new MemoryStream() ) |
| 652 | + { |
| 653 | + target.Pack( buffer, collection ); |
| 654 | + buffer.Position = 0; |
| 655 | + var unpacked = target.Unpack( buffer ); |
| 656 | + buffer.Position = 0; |
| 657 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 658 | + } |
| 659 | + } |
| 660 | + |
| 661 | + [Test] |
| 662 | + public void FSharpMapTest_0_Success() |
| 663 | + { |
| 664 | + var collection = new FSharpMap<int, int>( Enumerable.Empty<Tuple<int, int>>() ); |
| 665 | + var target = this.CreateTarget<FSharpMap<int, int>>(); |
| 666 | + using ( var buffer = new MemoryStream() ) |
| 667 | + { |
| 668 | + target.Pack( buffer, collection ); |
| 669 | + buffer.Position = 0; |
| 670 | + var unpacked = target.Unpack( buffer ); |
| 671 | + buffer.Position = 0; |
| 672 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 673 | + } |
| 674 | + } |
| 675 | + |
| 676 | + [Test] |
| 677 | + public void FSharpMapTest_1_Success() |
| 678 | + { |
| 679 | + var collection = new FSharpMap<int, int>( Enumerable.Empty<Tuple<int, int>>() ); |
| 680 | + collection = collection.Add( 0, 0 ); |
| 681 | + var target = this.CreateTarget<FSharpMap<int, int>>(); |
| 682 | + using ( var buffer = new MemoryStream() ) |
| 683 | + { |
| 684 | + target.Pack( buffer, collection ); |
| 685 | + buffer.Position = 0; |
| 686 | + var unpacked = target.Unpack( buffer ); |
| 687 | + buffer.Position = 0; |
| 688 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 689 | + } |
| 690 | + } |
| 691 | + |
| 692 | + [Test] |
| 693 | + public void FSharpMapTest_2_Success() |
| 694 | + { |
| 695 | + var collection = new FSharpMap<int, int>( Enumerable.Empty<Tuple<int, int>>() ); |
| 696 | + collection = collection.Add( 0, 0 ); |
| 697 | + collection = collection.Add( 1, 1 ); |
| 698 | + var target = this.CreateTarget<FSharpMap<int, int>>(); |
| 699 | + using ( var buffer = new MemoryStream() ) |
| 700 | + { |
| 701 | + target.Pack( buffer, collection ); |
| 702 | + buffer.Position = 0; |
| 703 | + var unpacked = target.Unpack( buffer ); |
| 704 | + buffer.Position = 0; |
| 705 | + Assert.That( unpacked.ToArray(), Is.EqualTo( collection.ToArray() ) ); |
| 706 | + } |
| 707 | + } |
| 708 | + |
| 709 | +#endif // !NETFX_CORE |
| 710 | + |
558 | 711 | } |
559 | 712 | } |
0 commit comments