Exemplo n.º 1
0
        public void EndTicksKeyPress()
        {
            // Setup
            HistoryEvent historyEvent = _history.AddCoreAction(CoreAction.KeyPress(100, 42, true));

            // Verify
            Assert.AreEqual(100, historyEvent.Ticks);
        }
Exemplo n.º 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 }));
 }
Exemplo n.º 3
0
        public void WriteSetCurrentRoot()
        {
            // Setup
            _history.AddCoreAction(CoreAction.KeyPress(100, 42, true));
            _history.CurrentEvent = _history.RootEvent;

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

            // Verify
            Assert.AreEqual(_fileInfo.History.RootEvent, _fileInfo.History.CurrentEvent);
        }
Exemplo n.º 4
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];
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void CloneKeyPress()
        {
            // Setup
            CoreAction action = CoreAction.KeyPress(100, 78, true);

            // Act
            CoreAction clone = action.Clone();

            // Verify
            Assert.AreEqual(CoreRequest.Types.KeyPress, clone.Type);
            Assert.AreEqual(100, clone.Ticks);
            Assert.AreEqual(78, clone.KeyCode);
            Assert.AreEqual(true, clone.KeyDown);
        }
Exemplo n.º 7
0
        public void WriteSetCurrentNonRoot()
        {
            // Setup
            _history.AddCoreAction(CoreAction.KeyPress(100, 42, true));
            HistoryEvent historyEvent = _history.AddCoreAction(CoreAction.KeyPress(100, 42, true));

            // Act
            _history.CurrentEvent = historyEvent;
            _fileInfo             = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(TestHelpers.HistoriesEqual(_history, _fileInfo.History));
            Assert.AreEqual(_fileInfo.History.CurrentEvent, _fileInfo.History.RootEvent.Children[0].Children[0]);
        }
Exemplo n.º 8
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);
        }