예제 #1
0
        public void CollapseRunUntilActions()
        {
            // Setup
            History history = new History();

            // Act
            CoreActionHistoryEvent event1 = history.AddCoreAction(CoreAction.RunUntil(100, 200, null));
            CoreActionHistoryEvent event2 = history.AddCoreAction(CoreAction.RunUntil(200, 300, null));

            // Verify
            Assert.AreEqual(1, history.RootEvent.Children.Count);
            Assert.AreEqual(event1, history.RootEvent.Children[0]);
            Assert.AreEqual(0, event1.Children.Count);
            Assert.AreEqual(event1, event2);
            Assert.AreEqual(CoreAction.Types.RunUntil, event1.CoreAction.Type);
            Assert.AreEqual(100, event1.CoreAction.Ticks);
            Assert.AreEqual(300, event1.CoreAction.StopTicks);
        }
예제 #2
0
        public void Open()
        {
            // Setup
            _mockTextFile.Clear();
            _machine.Persist(_mockFileSystem.Object, _filename);
            RunForAWhile(_machine);
            _machine.Key(Keys.A, true);
            RunForAWhile(_machine);
            _machine.LoadDisc(0, null);
            RunForAWhile(_machine);
            _machine.LoadTape(null);
            RunForAWhile(_machine);
            _machine.Reset();
            RunForAWhile(_machine);
            _machine.AddBookmark(false);
            HistoryEvent bookmarkEvent = _machine.History.CurrentEvent;

            RunForAWhile(_machine);
            _machine.JumpToMostRecentBookmark();
            HistoryEvent eventToDelete = bookmarkEvent.Children[0];

            RunForAWhile(_machine);
            _machine.DeleteBookmark(bookmarkEvent);
            _machine.DeleteBranch(eventToDelete);
            _machine.Close();

            using (LocalMachine machine = LocalMachine.OpenFromFile(_mockFileSystem.Object, "test.cpvc"))
            {
                // Verify
                Assert.IsTrue(machine.IsOpen);
                Assert.AreEqual(machine.PersistantFilepath, "test.cpvc");
                Assert.AreEqual(machine.Name, "test");

                Assert.IsInstanceOf <RootHistoryEvent>(machine.History.RootEvent);
                Assert.AreEqual(1, machine.History.RootEvent.Children.Count);

                CoreActionHistoryEvent coreActionHistoryEvent = machine.History.RootEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(CoreRequest.Types.KeyPress, coreActionHistoryEvent.CoreAction.Type);
                Assert.AreEqual(Keys.A, coreActionHistoryEvent.CoreAction.KeyCode);
                Assert.IsTrue(coreActionHistoryEvent.CoreAction.KeyDown);
                Assert.AreEqual(1, coreActionHistoryEvent.Children.Count);

                coreActionHistoryEvent = coreActionHistoryEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(CoreRequest.Types.LoadDisc, coreActionHistoryEvent.CoreAction.Type);
                Assert.AreEqual(0, coreActionHistoryEvent.CoreAction.Drive);
                Assert.IsNull(coreActionHistoryEvent.CoreAction.MediaBuffer.GetBytes());
                Assert.AreEqual(1, coreActionHistoryEvent.Children.Count);

                coreActionHistoryEvent = coreActionHistoryEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(CoreRequest.Types.LoadTape, coreActionHistoryEvent.CoreAction.Type);
                Assert.IsNull(coreActionHistoryEvent.CoreAction.MediaBuffer.GetBytes());
                Assert.AreEqual(1, coreActionHistoryEvent.Children.Count);

                coreActionHistoryEvent = coreActionHistoryEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(CoreRequest.Types.Reset, coreActionHistoryEvent.CoreAction.Type);
                Assert.AreEqual(1, coreActionHistoryEvent.Children.Count);

                coreActionHistoryEvent = coreActionHistoryEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(1, coreActionHistoryEvent.Children.Count);

                BookmarkHistoryEvent bookmarkHistoryEvent = coreActionHistoryEvent.Children[0] as BookmarkHistoryEvent;
                Assert.IsNotNull(bookmarkHistoryEvent);

                coreActionHistoryEvent = bookmarkHistoryEvent.Children[0] as CoreActionHistoryEvent;
                Assert.IsNotNull(coreActionHistoryEvent);
                Assert.AreEqual(CoreRequest.Types.RunUntil, coreActionHistoryEvent.CoreAction.Type);

                bookmarkHistoryEvent = coreActionHistoryEvent.Children[0] as BookmarkHistoryEvent;
                Assert.IsNotNull(bookmarkHistoryEvent);

                Assert.AreEqual(bookmarkHistoryEvent, machine.History.CurrentEvent);

                _mockAuditor.Verify(a => a(It.Is <CoreAction>(c => c.Type == CoreRequest.Types.LoadCore)), Times.Once);
            }
        }