Example #1
0
        public void SML_Instruction_Notequ_Bad_Stack_Items()
        {
            string[] inputOpcodes = new string[] { "5", "addone" };

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

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

            notequ.Run();
        }
Example #2
0
        public void SML_Instruction_Notequ_Bad_Item()
        {
            string[] inputOpcodes = new string[] { "2" };
            int      inputOne     = 2;
            string   inputTwo     = "1";

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

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

            stack.Push(inputOne);
            stack.Push(inputTwo);

            notequ.Run();
        }
Example #3
0
        public void SML_Instruction_Notequ_Good_None()
        {
            string[] inputOpcodes = new string[] { "addone" };
            int      inputOne     = 2;
            int      inputTwo     = 2;

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

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

            stack.Push(inputOne);
            stack.Push(inputTwo);

            notequ.Run();

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