Skip to content

Commit

Permalink
#13 added a failing test for reference tracking with removed field
Browse files Browse the repository at this point in the history
  • Loading branch information
AqlaSolutions committed Apr 21, 2016
1 parent 11b04d3 commit 5aae920
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
89 changes: 89 additions & 0 deletions protobuf-net.unittest/Aqla/ReferenceVersioningWithSkip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using AqlaSerializer.Meta;
using NUnit.Framework;

namespace AqlaSerializer.unittest.Aqla
{
[TestFixture]
public class ReferenceVersioningWithSkip
{
[SerializableType]
public class SimpleFoo
{
}

[SerializableType]
public class SourceSimple
{
[SerializableMember(1)]
public SimpleFoo Foo { get; set; }

[SerializableMember(2)]
public SimpleFoo SameFoo { get; set; }
}

[SerializableType]
public class DestinationSimple
{
[SerializableMember(2)]
public SimpleFoo SameFoo { get; set; }
}

[Test]
public void ChangeSimple()
{
var tm = TypeModel.Create();
var obj = new SourceSimple();
obj.Foo = obj.SameFoo = new SimpleFoo();
var changed = tm.ChangeType<SourceSimple, DestinationSimple>(obj);
Assert.That(changed.SameFoo, Is.Not.Null);
}

[Test]
public void ChangeComplex()
{
var tm = TypeModel.Create();
var obj = new SourceComplex();
obj.Bar = obj.SameBar = new SourceBar();
obj.Bar.Foo = obj.SameFoo = new SimpleFoo();
var changed = tm.ChangeType<SourceComplex, DestinationComplex>(obj);
Assert.That(changed.SameBar, Is.Not.Null);
Assert.That(changed.SameFoo, Is.Not.Null);
}

// recursive: removed property inside removed property
[SerializableType]
public class SourceBar
{
[SerializableMember(1)]
public SimpleFoo Foo { get; set; }
}

[SerializableType]
public class DestionationBar
{
}

[SerializableType]
public class SourceComplex
{
[SerializableMember(1)]
public SourceBar Bar { get; set; }

[SerializableMember(2)]
public SourceBar SameBar { get; set; }

[SerializableMember(3)]
public SimpleFoo SameFoo { get; set; }
}

[SerializableType]
public class DestinationComplex
{
[SerializableMember(2)]
public DestionationBar SameBar { get; set; }

[SerializableMember(3)]
public SimpleFoo SameFoo { get; set; }
}
}
}
1 change: 1 addition & 0 deletions protobuf-net.unittest/aqlaserializer.unittest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<Compile Include="Aqla\NestedLevelsTest.cs" />
<Compile Include="Aqla\NetObjectVersioning.cs" />
<Compile Include="Aqla\NullForLists.cs" />
<Compile Include="Aqla\ReferenceVersioningWithSkip.cs" />
<Compile Include="Aqla\SubTypeDebugSchema.cs" />
<Compile Include="Aqla\TooManyLevels.cs" />
<Compile Include="Attribs\Basic.cs" />
Expand Down

0 comments on commit 5aae920

Please sign in to comment.