-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added referenced (existing instance) deserializer overload for XmlReader
- Loading branch information
1 parent
c493567
commit e474001
Showing
2 changed files
with
92 additions
and
2 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
77 changes: 77 additions & 0 deletions
77
test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue630Tests.cs
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,77 @@ | ||
using ExtendedXmlSerializer.Configuration; | ||
using ExtendedXmlSerializer.ContentModel.Format; | ||
using ExtendedXmlSerializer.ExtensionModel.Instances; | ||
using ExtendedXmlSerializer.Tests.ReportedIssues.Support; | ||
using FluentAssertions; | ||
using System; | ||
using System.Xml.Serialization; | ||
using Xunit; | ||
|
||
namespace ExtendedXmlSerializer.Tests.ReportedIssues | ||
{ | ||
public sealed class Issue630Tests | ||
{ | ||
[Fact] | ||
public void Verify() | ||
{ | ||
var container = new ConfigurationContainer().Create().ForTesting(); | ||
var instance = new Terminate(true); | ||
container.Cycle(instance).All.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void VerifyPassThroughValue() | ||
{ | ||
var sut = new ConfigurationContainer().Type<Envelope>().WithMonitor(Monitor.Default).Create().ForTesting(); | ||
|
||
var instance = new Envelope { Version = 1.2f, SubObject = new() }; | ||
sut.Cycle(instance).SubObject.Version.Should().Be(1.2f); | ||
} | ||
|
||
sealed class Monitor : ISerializationMonitor<Envelope> | ||
{ | ||
public static Monitor Default { get; } = new(); | ||
|
||
Monitor() {} | ||
|
||
public void OnSerializing(IFormatWriter writer, Envelope instance) {} | ||
|
||
public void OnSerialized(IFormatWriter writer, Envelope instance) {} | ||
|
||
public void OnDeserializing(IFormatReader reader, Type instanceType) {} | ||
|
||
public void OnActivating(IFormatReader reader, Type instanceType) {} | ||
|
||
public void OnActivated(Envelope instance) {} | ||
|
||
public void OnDeserialized(IFormatReader reader, Envelope instance) | ||
{ | ||
instance.SubObject.Version = instance.Version; | ||
} | ||
} | ||
|
||
sealed class Envelope | ||
{ | ||
public float Version {get; set;} | ||
public SubObject SubObject { get; set; } | ||
} | ||
sealed class SubObject { | ||
public string Name {get; set;} | ||
public float Version {get; set;} | ||
} | ||
|
||
|
||
public sealed class Terminate { | ||
public Terminate() : this(null) {} | ||
|
||
public Terminate(bool? all) => _all = all; | ||
|
||
[XmlElement(ElementName = "All")] | ||
private bool? _all = null; | ||
public bool All { | ||
get { return _all != null; } | ||
} | ||
} | ||
|
||
} | ||
} |