public void PushChild_NullParent_NonNullObject() { _session = ConstructSession(); var childObject = new object(); _session.PushObject(new ObjectBuildRecord(typeof(object), null, true)); var expectedParent = _session.CurrentObject; _session.PushObject(new ObjectBuildRecord(typeof(object), childObject, true)); Assert.AreSame(childObject, _session.CurrentObject.Object); Assert.AreEqual(1, _session.BuildDepth); Assert.AreSame(expectedParent, _session.CurrentObject.Parent); }
private DisposableAction PushChild <TType>(TType obj, int expectedDepth) { var disposable = _session.PushObject(new ObjectBuildRecord(typeof(TType), obj, true)); Assert.AreEqual(expectedDepth, NextInSequence()); return(disposable); }
public void PopChild_DoublePush_SinglePop() { var expectedObj = new object(); var expectedChild = new object(); _session = ConstructSession(); var expectedParent = _session.CurrentObject; _session.PushObject(new ObjectBuildRecord(typeof(object), expectedObj, true)); using (_session.PushObject(new ObjectBuildRecord(typeof(object), expectedChild, true))){} Assert.AreSame(expectedObj, _session.CurrentObject.Object); Assert.AreEqual(0, _session.BuildDepth); Assert.AreSame(expectedParent, _session.CurrentObject.Parent); Assert.AreEqual(1, _session.CurrentObject.Children.Count); Assert.AreSame(expectedChild, _session.CurrentObject.Children[0].Object); }
public void PopChild_SinglePush_SinglePop() { _session = ConstructSession(); using (_session.PushObject(new ObjectBuildRecord(typeof(object), new object(), true))){} Assert.IsNull(_session.CurrentObject.Object); Assert.AreEqual(-1, _session.BuildDepth); Assert.IsNull(_session.CurrentObject.Parent); }
public void Create_SimpleType_NamedMember() { var session = new BuildSession(null, null, new Random(0)); var obj = new SimpleType(); session.PushObject(new ObjectBuildRecord(typeof(SimpleType), obj, true)); session.PushMember(MemberExpressions.GetMemberInfo <SimpleType>(c => c.NamedMember)); Assert.AreEqual("NamedMember0", Generator.CreateRecord(typeof(string), null, session).Object); Assert.AreEqual("NamedMember1", Generator.CreateRecord(typeof(string), null, session).Object); Assert.AreEqual("NamedMember2", Generator.CreateRecord(typeof(string), null, session).Object); }
public void PushChild_NullObject() { _session = ConstructSession(); var expectedParent = _session.CurrentObject; _session.PushObject(new ObjectBuildRecord(typeof(object), null, true)); Assert.IsNull(_session.CurrentObject.Object); Assert.AreEqual(0, _session.BuildDepth); Assert.AreSame(expectedParent, _session.CurrentObject.Parent); Assert.AreEqual(1, _session.CurrentObject.Parent.Children.Count); Assert.IsNull(_session.CurrentObject.Parent.Children[0].Object); Assert.AreEqual(1, _session.ConstructedNodes.Count); Assert.IsNotNull(_session.ConstructedNodes[0]); Assert.IsNull(_session.ConstructedNodes[0].Object); }
public void PushChild_SimpleObject() { var testObject = new object(); _session = ConstructSession(); var expectedParent = _session.CurrentObject; _session.PushObject(new ObjectBuildRecord(typeof(object), testObject, true)); Assert.AreSame(testObject, _session.CurrentObject.Object); Assert.AreEqual(0, _session.BuildDepth); Assert.AreSame(expectedParent, _session.CurrentObject.Parent); Assert.AreEqual(1, _session.CurrentObject.Parent.Children.Count); Assert.AreSame(testObject, _session.CurrentObject.Parent.Children[0].Object); Assert.AreEqual(1, _session.ConstructedNodes.Count); Assert.AreSame(testObject, _session.ConstructedNodes[0].Object); }