public void ViewPortReloadsIfNoLocalChangesWhenFileChanges()
        {
            var    fileSystem = new StubFileSystem();
            string file       = null;

            fileSystem.LoadFile = input => { file = input; return(new LoadedFile(input, new byte[] { 0x10, 0x20 })); };
            var viewPort = new ViewPort(new LoadedFile("file.txt", new byte[] { 0x00, 0x00 }));

            viewPort.ConsiderReload(fileSystem);

            Assert.Equal("file.txt", file);
            Assert.Equal(0x10, viewPort[0, 0].Value);
        }
Beispiel #2
0
        public void ViewPortRequestsDelayedReloadIfReloadFails()
        {
            var viewPort   = new ViewPort(new LoadedFile("file.txt", new byte[50]));
            var fileSystem = new StubFileSystem {
                LoadFile = fileName => throw new IOException()
            };

            var retryCount = 0;

            viewPort.RequestDelayedWork += (sender, e) => retryCount++;

            viewPort.ConsiderReload(fileSystem);

            Assert.Equal(1, retryCount);
        }
Beispiel #3
0
        public void ViewPortAdjustsSelectionWhenLoadingAShorterFile()
        {
            var viewPort = new ViewPort(new LoadedFile("file.txt", new byte[12]));

            viewPort.SelectionStart = new Point(3, 3);
            Assert.Equal(4, viewPort.Width);
            Assert.Equal(4, viewPort.Height);
            Assert.Equal(new Point(0, 3), viewPort.SelectionStart);

            var fileSystem = new StubFileSystem {
                LoadFile = filename => new LoadedFile("file.txt", new byte[10])
            };

            viewPort.ConsiderReload(fileSystem);

            Assert.Equal(new Point(2, 2), viewPort.SelectionStart);
        }