Exemplo n.º 1
0
        public void MissingColon()
        {
            // Setup
            _mockFile.WriteLine("key");

            // Act and Verify
            Assert.Throws <Exception>(() => _fileInfo = MachineFile.Read(_mockFile));
        }
Exemplo n.º 2
0
        public void WriteAndReadCoreAction(CoreAction coreAction)
        {
            // Act
            _history.AddCoreAction(coreAction, 123456);
            _fileInfo = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(HistoriesEqual(_fileInfo.History, _history));
        }
Exemplo n.º 3
0
        public void DeleteInvalidBranch()
        {
            // Setup
            _mockFile.WriteLine("key:0,100,42,True");
            _mockFile.WriteLine("deletebranch:0");

            // Act and Verify
            Assert.Throws <InvalidOperationException>(() => _fileInfo = MachineFile.Read(_mockFile));
        }
Exemplo n.º 4
0
        public void WriteAndReadRunUntil()
        {
            // Act
            _history.AddCoreAction(CoreAction.RunUntil(100, 200, null));
            _history.CurrentEvent = _history.RootEvent;
            _fileInfo             = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(HistoriesEqual(_fileInfo.History, _history));
        }
Exemplo n.º 5
0
        public void ReadUnknown()
        {
            // Setup
            _mockFile.WriteLine("unknown:\r\n");

            // Act and Verify
            ArgumentException ex = Assert.Throws <ArgumentException>(() => _fileInfo = MachineFile.Read(_mockFile));

            Assert.AreEqual("type", ex.ParamName);
        }
Exemplo n.º 6
0
        public void ReadDeleteBranchInvalid()
        {
            // Setup
            _mockFile.WriteLine("deletebranch:42\r\n");

            // Act and Verify
            ArgumentException ex = Assert.Throws <ArgumentException>(() => _fileInfo = MachineFile.Read(_mockFile));

            Assert.AreEqual("id", ex.ParamName);
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
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.º 9
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.º 10
0
        public void WriteAndReadName()
        {
            // Setup
            LocalMachine machine = LocalMachine.New(String.Empty, null);

            _file.Machine = machine;

            // Act
            machine.Name = "Test";
            _fileInfo    = MachineFile.Read(_mockFile);

            // Verify
            Assert.AreEqual(machine.Name, _fileInfo.Name);
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
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));
        }
Exemplo n.º 13
0
        public void WriteAndReadDelete()
        {
            // Setup
            Bookmark bookmark = new Bookmark(false, 1, new byte[] { 0x01, 0x02 }, new byte[] { 0x03, 0x04 });

            // Act
            _history.AddBookmark(100, bookmark);
            HistoryEvent historyEvent = _history.CurrentEvent;

            _history.CurrentEvent = _history.RootEvent;
            _history.DeleteBookmark(historyEvent);
            _fileInfo = MachineFile.Read(_mockFile);

            // Verify
            Assert.True(HistoriesEqual(_fileInfo.History, _history));
        }
Exemplo n.º 14
0
        public void WriteAndReadArguments()
        {
            // Setup
            Bookmark bookmark = new Bookmark(false, 1, _state, _screen);

            // Act
            _history.AddBookmark(100, bookmark);
            _history.AddBookmark(200, bookmark);
            _mockFile.Clear();
            _file.WriteHistory("Test");
            _fileInfo = MachineFile.Read(_mockFile);

            // Verify
            Assert.AreEqual(1, _mockFile.Lines.Count(line => line.StartsWith("args:")));
            Assert.Zero(_mockFile.Lines.Count(line => line.StartsWith("arg:")));
            Assert.True(HistoriesEqual(_fileInfo.History, _history));
        }