Exemplo n.º 1
0
        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)
            ;
        }
Exemplo n.º 2
0
        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)
            ;
        }
Exemplo n.º 3
0
        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()
            ;
        }
Exemplo n.º 4
0
        public void Should_not_jump_if_objectA_is_NOT_child_of_objectB()
        {
            const ushort parent    = 1234;
            const ushort notParent = 4321;

            Mockery.SetNextObject(
                new ZMachineObjectBuilder()
                .WithParent(parent)
                .Build()
                );

            Operation.Execute(new OperandBuilder()
                              .WithArgs(parent, notParent)
                              .Build());

            Mockery.JumpedWith(false);
        }
Exemplo n.º 5
0
        public void Should_clear_attribute()
        {
            ushort obj       = 1234;
            ushort attribute = 0x02;
            var    args      = new OperandBuilder()
                               .WithArg(obj)
                               .WithArg(attribute)
                               .Build();

            var zObj        = new Mock <IZMachineObject>();
            var zAttributes = new Mock <IZAttributes>();

            zObj.Setup(z => z.Attributes).Returns(zAttributes.Object);
            Mockery.SetNextObject(zObj.Object);

            Operation.Execute(args);

            zAttributes.Verify(o => o.ClearAttribute((byte)It.Is <byte>(v => v == attribute)));
        }
Exemplo n.º 6
0
        public void Should_jump_if_objectA_is_child_of_objectB()
        {
            ushort parent = 1234;

            Mockery.SetNextObject(
                new ZMachineObjectBuilder()
                .WithParent(parent)
                .Build()
                );

            var operands = new OperandBuilder()
                           .WithAnyArg()
                           .WithArg(parent)
                           .Build();

            Operation.Execute(operands);

            Mockery.JumpedWith(true);
        }
Exemplo n.º 7
0
        public void Should_print_the_object_name()
        {
            var args = new OperandBuilder()
                       .WithArg(0)
                       .Build();

            var objectName = "My Object";

            Mockery
            .SetNextObject(new ZMachineObjectBuilder()
                           .WithName(objectName).Build());

            Operation.Execute(args);



            Mockery
            // TODO: Check that a packed address was used
            .Printed(objectName)
            ;
        }