Skip to content

Commit

Permalink
+ repro test case for issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostousov committed Jun 2, 2018
1 parent 24a8bfc commit 024b04b
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions GroBuf.Tests/TestReproForIssue5.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using GroBuf.DataMembersExtracters;

using NUnit.Framework;

namespace GroBuf.Tests
{
[Explicit("repro for https://github.com/skbkontur/GroBuf/issues/5")]
public class TestReproForIssue5
{
[Test]
public void AbstractProperty()
{
var bytes = serializer.Serialize(new DerivedWithAbstractProp(42));
Assert.That(serializer.Deserialize<DerivedWithAbstractProp>(bytes).Prop, Is.EqualTo(42));
}

[Test]
public void VirtualProperty()
{
var bytes = serializer.Serialize(new DerivedWithVirtualProp(42));
Assert.That(serializer.Deserialize<DerivedWithVirtualProp>(bytes).Prop, Is.EqualTo(42));
}

private readonly Serializer serializer = new Serializer(new AllPropertiesExtractor(), null, GroBufOptions.MergeOnRead);

private abstract class BaseWithVirtualProp
{
public virtual int Prop { get; }
}

private class DerivedWithVirtualProp : BaseWithVirtualProp
{
public DerivedWithVirtualProp(int prop)
{
Prop = prop;
}

public override int Prop { get; }
}

private abstract class BaseWithAbstractProp
{
public abstract int Prop { get; }
}

private class DerivedWithAbstractProp : BaseWithAbstractProp
{
public DerivedWithAbstractProp(int prop)
{
Prop = prop;
}

public override int Prop { get; }
}
}
}

0 comments on commit 024b04b

Please sign in to comment.