-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#13 added a failing test for reference tracking with removed field
- Loading branch information
1 parent
11b04d3
commit 5aae920
Showing
2 changed files
with
90 additions
and
0 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
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; } | ||
} | ||
} | ||
} |
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