Example #1
0
        public void EndTicksReset()
        {
            // Setup
            HistoryEvent historyEvent = _history.AddCoreAction(CoreAction.Reset(100));

            // Verify
            Assert.AreEqual(100, historyEvent.Ticks);
        }
Example #2
0
 public void SetUp()
 {
     _history = new History();
     _event0  = _history.AddCoreAction(CoreAction.RunUntil(100, 200, null));
     _event00 = _history.AddCoreAction(CoreAction.KeyPress(200, 12, true));
     _history.CurrentEvent = _event0;
     _event01  = _history.AddCoreAction(CoreAction.Reset(300));
     _event010 = _history.AddBookmark(400, new Bookmark(false, 1, new byte[] { 0x01, 0x02 }, new byte[] { 0x03, 0x04 }));
 }
Example #3
0
        public void SetBookmark()
        {
            // Setup
            History      history = new History();
            HistoryEvent event1  = history.AddCoreAction(CoreAction.RunUntil(100, 200, null));
            HistoryEvent event2  = history.AddCoreAction(CoreAction.KeyPress(200, 12, true));

            // Act
            HistoryEvent event3 = history.AddBookmark(200, new Bookmark(false, Core.LatestVersion, new byte[] { }, new byte[] { }));

            // Verify
            Assert.AreEqual(event3, history.CurrentEvent);
            Assert.IsInstanceOf <BookmarkHistoryEvent>(event3);
        }
Example #4
0
        public void AddEvent()
        {
            // Setup
            History history = new History();

            // Act
            HistoryEvent event1 = history.AddCoreAction(CoreAction.RunUntil(100, 200, null));
            HistoryEvent event2 = history.AddCoreAction(CoreAction.KeyPress(200, 12, true));

            // Verify
            Assert.AreEqual(1, history.RootEvent.Children.Count);
            Assert.AreEqual(event1, history.RootEvent.Children[0]);
            Assert.AreEqual(1, event1.Children.Count);
            Assert.AreEqual(event2, event1.Children[0]);
            Assert.AreEqual(0, event2.Children.Count);
        }
Example #5
0
        public void WriteAndReadCoreAction(CoreAction coreAction)
        {
            // Act
            _history.AddCoreAction(coreAction, 123456);
            _fileInfo = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(HistoriesEqual(_fileInfo.History, _history));
        }
Example #6
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);
        }
Example #7
0
        public void SetBookmarkBadTicks()
        {
            // Setup
            History      history = new History();
            HistoryEvent event1  = history.AddCoreAction(CoreAction.RunUntil(100, 200, null));

            // Act and Verify
            Assert.Throws <Exception>(() => history.AddBookmark(99, new Bookmark(false, Core.LatestVersion, new byte[] { }, new byte[] { })));
        }
Example #8
0
        public void ReadUncompressedArgument()
        {
            // Setup
            History expectedHistory = new History();

            expectedHistory.AddCoreAction(CoreAction.LoadTape(100, new MemoryBlob(new byte[] { 0x01, 0x02 })));
            _mockFile.WriteLine(String.Format("arg:1,False,0102"));
            _mockFile.WriteLine("tape:0,100,$1");

            // Act
            _fileInfo = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(TestHelpers.HistoriesEqual(expectedHistory, _fileInfo.History));
        }
Example #9
0
        public void Setup()
        {
            MockTextFile mockTextFile = new MockTextFile();

            _mockFileSystem = new Mock <IFileSystem>(MockBehavior.Strict);
            _mockFileSystem.Setup(fileSystem => fileSystem.OpenTextFile(AnyString())).Returns(mockTextFile);
            _mockFileSystem.Setup(fileSystem => fileSystem.DeleteFile(AnyString()));
            _mockFileSystem.Setup(fileSystem => fileSystem.ReplaceFile(AnyString(), AnyString()));
            _mockFileSystem.Setup(ReadBytes()).Returns(new byte[1]);

            _history = new History();

            _bookmark1Event = _history.AddBookmark(100, new Bookmark(false, 0, null, null));
            _history.AddCoreAction(CoreAction.RunUntil(100, 400, null));
            _leaf1Event           = _history.AddCoreAction(CoreAction.KeyPress(400, 42, true));
            _history.CurrentEvent = _bookmark1Event;
            _bookmark2Event       = _history.AddBookmark(200, new Bookmark(false, 0, null, null));
            _history.AddCoreAction(CoreAction.RunUntil(200, 300, null));
            _leaf2Event           = _history.AddCoreAction(CoreAction.KeyPress(300, 42, true));
            _history.CurrentEvent = _bookmark2Event;
            _history.AddCoreAction(CoreAction.KeyPress(300, 42, true));
            _history.AddCoreAction(CoreAction.KeyPress(400, 42, false));
            _bookmark3Event       = _history.AddBookmark(500, new Bookmark(false, 0, null, null));
            _history.CurrentEvent = _history.RootEvent;
            _leaf3Event           = _history.AddCoreAction(CoreAction.KeyPress(50, 42, true));
            _history.CurrentEvent = _bookmark3Event;


            // Diagram of this history...
            //
            // 500: o
            // 400: |   |
            // 300: | | |
            // 200: o-/ |
            // 100: o---/
            //  50  |     |
            //   0: o-----/

            _viewModel = new BookmarksViewModel(_history);

            Assert.AreEqual(7, _viewModel.Items.Count);

            _bookmark3ViewItem = _viewModel.Items[0];
            _leaf1ViewItem     = _viewModel.Items[1];
            _leaf2ViewItem     = _viewModel.Items[2];
            _bookmark2ViewItem = _viewModel.Items[3];
            _bookmark1ViewItem = _viewModel.Items[4];
            _leaf3ViewItem     = _viewModel.Items[5];
            _rootViewItem      = _viewModel.Items[6];
        }