public void CursorPositionFixer_PostSingleCRLF_ReturnsSamePosition() { var initialCursorPosition = 3; var fixer = new CursorPositionFixer(); var fixedCursorPosition = fixer.Fix( file: CRLFEndingFile(), cursorPosition: initialCursorPosition); var realCursorPosition = 3; Assert.AreEqual(realCursorPosition, fixedCursorPosition); }
public void CursorPositionFixer_PreLF_ReturnsSamePositionMinusOne() { var initialCursorPosition = 1; var fixer = new CursorPositionFixer(); var fixedCursorPosition = fixer.Fix( file: LFEndingFile(), cursorPosition: initialCursorPosition); var realCursorPosition = initialCursorPosition - 1; Assert.AreEqual(realCursorPosition, fixedCursorPosition); }
public void CursorPositionFixer_PostMultipleCRLF_ReturnsPositionPlusCRMinusOne() { var initialCursorPosition = 10; var fixer = new CursorPositionFixer(); var fixedCursorPosition = fixer.Fix( file: CRLFEndingFile(), cursorPosition: initialCursorPosition); var realCursorPosition = 12; Assert.AreEqual(realCursorPosition, fixedCursorPosition); }
public SourceMonitor(IServiceProvider serviceProvider) { ServiceProvider = serviceProvider; CursorPositionFixer = new CursorPositionFixer(); Timer = new Timer(1000); Timer.AutoReset = false; Timer.Elapsed += (sender, args) => { try { PeriodicTaskCore(); } catch (Exception e) { LastThreadException = e; } Timer.Start(); }; Timer.Start(); }
public void CursorPositionFixer_WithMissingFile_ReturnsSamePosition() { var initialCursorPosition = 1; var fixer = new CursorPositionFixer(); var fixedCursorPosition = fixer.Fix( file: @"C:\missing.file", cursorPosition: initialCursorPosition); Assert.AreEqual(initialCursorPosition, fixedCursorPosition); }