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]; }
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 })); }
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[] { }))); }
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); }
public void ReadUncompressedArguments() { // Setup History expectedHistory = new History(); expectedHistory.AddBookmark(100, new Bookmark(true, 1, _state, _screen), new DateTime(123456789, DateTimeKind.Utc)); _mockFile.WriteLine(String.Format("args:False,1#{0}@2#{1}", Helpers.StrFromBytes(_state), Helpers.StrFromBytes(_screen))); _mockFile.WriteLine("bookmark:0,100,True,1,123456789,$1,$2"); // Act _fileInfo = MachineFile.Read(_mockFile); // Verify Assert.True(TestHelpers.HistoriesEqual(expectedHistory, _fileInfo.History)); }
public void WriteAndReadBookmark() { // Setup Bookmark bookmark = new Bookmark(false, 1, new byte[] { 0x01, 0x02 }, new byte[] { 0x03, 0x04 }); // Act _history.AddBookmark(100, bookmark); _fileInfo = MachineFile.Read(_mockFile); // Verify Assert.True(HistoriesEqual(_fileInfo.History, _history)); }