Beispiel #1
0
        public void SML_Instruction_Equint_Bad_Stack()
        {
            string[] inputOpcodes = new string[] { "2", "addone" };

            Stack stack = new Stack();
            Mock <IVirtualMachine> mock = new Mock <IVirtualMachine>(MockBehavior.Strict);
            Equint equint = new Equint
            {
                VirtualMachine = mock.Object,
                Operands       = inputOpcodes
            };

            mock.Setup(m => m.Stack).Returns(new Stack());
            mock.Setup(m => m.SwapBranch(It.IsAny <string>()));

            equint.Run();
        }
Beispiel #2
0
        public void SML_Instruction_Equint_Not_Called()
        {
            string[] inputOpcodes = new string[] { "1", "addone" };
            int      inputOne     = 2;

            Stack stack = new Stack();
            Mock <IVirtualMachine> mock = new Mock <IVirtualMachine>(MockBehavior.Strict);
            Equint equint = new Equint
            {
                VirtualMachine = mock.Object,
                Operands       = inputOpcodes
            };

            mock.Setup(m => m.Stack).Returns(stack);
            mock.Setup(m => m.SwapBranch(It.IsAny <string>()));

            stack.Push(inputOne);

            equint.Run();

            mock.Verify(m => m.SwapBranch(It.IsAny <string>()), Times.Never);
        }