Esempio n. 1
0
        public void testGPSimRunsToPortBreakpoint()
        {
            gpSim uut = null;
            try
            {
                uut = new gpSim(_knownGoodHexFile, _handerForm.Object);

                // Add a breakpoint on PORTB.
                breakpoint brk = new breakpoint(){callback = this.handler,location = "portb"};
                uut.addWriteBreakpoint(brk);

                // and then run the node.
                uut.run();

                 // Now wait for our handler to be called.
                int timeout = 1000;
                while(!handlerCalled)
                {
                    Thread.Sleep(1000);
                    timeout--;

                    if (timeout == 0)
                        throw new TimeoutException();
                }
                _handerForm.Verify(i => i.BeginInvoke(It.IsAny<gpSim.breakpointHandler>(), It.Is<object[]>(x => x == new object[] { uut, brk })), Times.Once());

                // OK, the handler was called. Ace. Ensure that it was set to the
                // correct value.
                Assert.AreEqual(0x01, portState & 0x01);
            }
            finally
            {
                if (uut != null)
                    uut.Dispose();
            }
        }
Esempio n. 2
0
 private void handler(gpSim sender, breakpoint hit)
 {
     portState = sender.readMemory("portb");
     handlerCalled = true;
 }