Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incomplete attempt to integrate endpoint-behaviour
git-svn-id: http://protobuf-net.googlecode.com/svn/trunk@273 b72047a4-3652-0410-9617-b3994939e97b
- Loading branch information
marc.gravell
committed
Oct 8, 2009
1 parent
0bd09d9
commit b16ec9b
Showing
31 changed files
with
1,597 additions
and
931 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,60 @@ | ||
using NUnit.Framework; | ||
using ProtoBuf; | ||
using System.IO; | ||
|
||
namespace Examples.Issues | ||
{ | ||
[TestFixture, Ignore("not sure we want to support this")] | ||
public class Issue70 { | ||
|
||
[ProtoContract] | ||
public class Strange // test entity | ||
{ | ||
[ProtoMember(1)] | ||
public string Foo { get; set; } // test prop | ||
[ProtoMember(2)] | ||
public int Bar { get; set; } // test prop | ||
} | ||
|
||
[Test] | ||
public void SerializaeWithLengthPrefixShouldWorkWithBase128() | ||
{ | ||
var original = new Strange { Foo = "abc", Bar = 123 }; | ||
// serialize and deserialize with base-128 | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
Serializer.SerializeWithLengthPrefix(ms, original, PrefixStyle.Base128, 1); | ||
ms.Position = 0; | ||
object obj; | ||
Serializer.NonGeneric.TryDeserializeWithLengthPrefix(ms, | ||
PrefixStyle.Base128, i => typeof(Strange), out obj); | ||
var clone = (Strange)obj; | ||
Assert.AreNotSame(original, clone); | ||
Assert.IsNotNull(clone); | ||
Assert.AreEqual(original.Foo, clone.Foo, "Foo"); | ||
Assert.AreEqual(original.Bar, clone.Bar, "Bar"); | ||
} | ||
} | ||
[Test] | ||
public void SerializaeWithLengthPrefixShouldWorkWithFixed32() | ||
{ | ||
var original = new Strange { Foo = "abc", Bar = 123 }; | ||
// serialize and deserialize with fixed-32 | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
Serializer.SerializeWithLengthPrefix(ms, original, PrefixStyle.Fixed32, 1); | ||
ms.Position = 0; | ||
object obj; | ||
// BOOM here; oh how embarrassing | ||
Serializer.NonGeneric.TryDeserializeWithLengthPrefix(ms, | ||
PrefixStyle.Fixed32, i => typeof(Strange), out obj); | ||
var clone = (Strange)obj; | ||
Assert.AreNotSame(original, clone); | ||
Assert.IsNotNull(clone); | ||
Assert.AreEqual(original.Foo, clone.Foo, "Foo"); | ||
Assert.AreEqual(original.Bar, clone.Bar, "Bar"); | ||
} | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.