public void Should_store_child_and_jump() { const int objectNumber = 10; const int child = 15; var args = new OperandBuilder() .WithArg(AnyVariable) .Build(); var zObj = new ZMachineObjectBuilder() .WithObjectNumber(objectNumber) .WithChild(child) .Build(); Mockery .SetNextObject(zObj); Operation.Execute(args); Mockery .ResultDestinationRetrievedFromPC() .ResultStoredWasByte(child) .JumpedWith(true) ; }
public void Should_not_jump_when_sibling_is_zero() { const int objectNumber = 10; const int sibling = 0; var args = new OperandBuilder() .WithArg(objectNumber) .Build(); var zObj = new ZMachineObjectBuilder() .WithObjectNumber(objectNumber) .WithSibling(sibling) .Build(); Mockery .SetNextObject(zObj); Operation.Execute(args); Mockery .ResultDestinationRetrievedFromPC() .ResultStoredWasByte(sibling) .JumpedWith(false) ; }
public void Should_store_parent_and_never_jump() { const int objectNumber = 10; const int parent = 25; var args = new OperandBuilder() .WithArg(AnyVariable) .Build(); var zObj = new ZMachineObjectBuilder() .WithObjectNumber(objectNumber) .WithParent(parent) .Build(); Mockery .SetNextObject(zObj); Operation.Execute(args); Mockery .ResultDestinationRetrievedFromPC() .ResultStoredWasByte(parent) .NeverJumps() ; }
public void Should_remove_immediate_child() { ushort child = 20; ushort child2 = 25; ushort sibling = 30; ushort parent = 5; ushort objectToRemove = child; var(childZObj, parentZObj, _) = ZMachineObjectBuilder.BuildSimpleRelationship(parent, child, sibling, child2); Mockery .SetGetObject(child, childZObj) .SetGetObject(parent, parentZObj); var args = new OperandBuilder() .WithArg(objectToRemove) .Build(); Operation.Execute(args); parentZObj.Child.ShouldBe(childZObj.Sibling); childZObj.Parent.ShouldBe((ushort)0); }