public void RoundtripDerivedClassWithSerializeAs() { var obj = new InheritanceExample { SomeScalar = "Hello", BaseWithSerializeAs = new Derived { BaseProperty = "foo", DerivedProperty = "bar" }, }; var result = DoRoundtripFromObjectTo <InheritanceExample>(obj, RoundtripSerializer); result.BaseWithSerializeAs.Should().BeOfType <Base>().And .Subject.As <Base>().ShouldHave().SharedProperties().EqualTo(new { ParentProp = "foo" }); }
public void RoundtripDerivedClassWithSerializeAs() { var obj = new InheritanceExample { SomeScalar = "Hello", BaseWithSerializeAs = new Derived { BaseProperty = "foo", DerivedProperty = "bar" }, }; var result = DoRoundtripFromObjectTo <InheritanceExample>(obj, RoundtripSerializer); result.BaseWithSerializeAs.Should().BeOfType <Base>().And .Subject.As <Base>().ShouldBeEquivalentTo(new { ParentProp = "foo" }, o => o.ExcludingMissingMembers()); }
// Todo: is the assert on the string necessary? public void RoundtripDerivedClass() { var obj = new InheritanceExample { SomeScalar = "Hello", RegularBase = new Derived { BaseProperty = "foo", DerivedProperty = "bar" }, }; var result = DoRoundtripFromObjectTo <InheritanceExample>(obj, RoundtripSerializer); result.SomeScalar.Should().Be("Hello"); result.RegularBase.Should().BeOfType <Derived>().And .Subject.As <Derived>().ShouldHave().SharedProperties().EqualTo(new { ChildProp = "bar" }); }
// Todo: is the assert on the string necessary? public void RoundtripDerivedClass() { var obj = new InheritanceExample { SomeScalar = "Hello", RegularBase = new Derived { BaseProperty = "foo", DerivedProperty = "bar" }, }; var result = DoRoundtripFromObjectTo <InheritanceExample>(obj, RoundtripSerializer); result.SomeScalar.Should().Be("Hello"); result.RegularBase.Should().BeOfType <Derived>().And .Subject.As <Derived>().ShouldBeEquivalentTo(new { ChildProp = "bar" }, o => o.ExcludingMissingMembers()); }