public void OpenTextFile() { // Setup string filepath = TestHelpers.GetTempFilepath("test.txt"); FileSystem fs = new FileSystem(); fs.DeleteFile(filepath); // Act using (ITextFile textFile = fs.OpenTextFile(filepath)) { textFile.WriteLine("abc"); textFile.WriteLine("123"); } List <string> lines = new List <string>(); using (ITextFile textFile = fs.OpenTextFile(filepath)) { lines.Add(textFile.ReadLine()); lines.Add(textFile.ReadLine()); lines.Add(textFile.ReadLine()); } // Verify Assert.AreEqual("abc", lines[0]); Assert.AreEqual("123", lines[1]); Assert.Null(lines[2]); fs.DeleteFile(filepath); }
public void ReadFile(ITextFile textFile) { _idToHistoryEvent = new Dictionary <int, HistoryEvent>(); _args = new Dictionary <int, string>(); _name = null; _machineHistory = new History(); _idToHistoryEvent[_machineHistory.RootEvent.Id] = _machineHistory.RootEvent; string line; while ((line = textFile.ReadLine()) != null) { ProcessLine(line); } }