public void ReadTwice() { SystemPath filename = tempDir.CreateEmptyFile("Twice.Log"); ServerLogFileReader reader = new ServerLogFileReader(filename.ToString(), 10); String first = reader.Read(); String second = reader.Read(); Assert.AreEqual(first, second, "Error reading file twice with same reader"); }
public void ReadOutputFromSpecifiedProject() { string content = @"2006-11-24 20:09:52,000 [CCNet Server:INFO] Starting CruiseControl.NET Server 2006-11-24 20:09:53,000 [foo:INFO] Starting integrator for project: foo 2006-11-24 20:09:54,000 [bar:INFO] Starting integrator for project: bar 2006-11-24 20:09:55,000 [foo:INFO] No modifications detected 2006-11-24 20:09:56,000 [bar:INFO] No modifications detected."; SystemPath tempFile = tempDir.CreateTextFile("MultiProject.log", content); ServerLogFileReader reader = new ServerLogFileReader(tempFile.ToString(), 10); Assert.AreEqual(@"2006-11-24 20:09:53,000 [foo:INFO] Starting integrator for project: foo 2006-11-24 20:09:55,000 [foo:INFO] No modifications detected", reader.Read("foo")); Assert.AreEqual(@"2006-11-24 20:09:54,000 [bar:INFO] Starting integrator for project: bar 2006-11-24 20:09:56,000 [bar:INFO] No modifications detected.", reader.Read("bar")); }
public void ReadUnknownFile() { ServerLogFileReader reader = new ServerLogFileReader("BogusFileName", 10); Assert.That(delegate { reader.Read(); }, Throws.TypeOf <FileNotFoundException>()); }
public void ReadEmptyFile() { SystemPath filename = tempDir.CreateEmptyFile("ReadEmptyFile.log"); ServerLogFileReader reader = new ServerLogFileReader(filename.ToString(), 10); Assert.AreEqual("", reader.Read(), "Error reading empty log file"); }
public void ReadSingleLineFromLogFile() { string content = @"SampleLine"; SystemPath filename = tempDir.CreateTextFile("ReadSingleLineFromLogFile.log", content); ServerLogFileReader reader = new ServerLogFileReader(filename.ToString(), 10); Assert.AreEqual(content, reader.Read()); }
public void ReadFromLockedLogFile() { SystemPath tempFile = tempDir.CreateEmptyFile("LockedFilename.log"); using (StreamWriter stream = File.CreateText(tempFile.ToString())) { stream.Write("foo"); stream.Write("bar"); stream.Flush(); ServerLogFileReader reader = new ServerLogFileReader(tempFile.ToString(), 10); Assert.AreEqual("foobar", reader.Read()); } }
public void ReadExactInFile() { const int numLines = 10; string[] contentLines = GenerateContentLines(numLines); SystemPath filename = tempDir.CreateTextFile("ReadExactInFile.log", LinesToString(contentLines)); ServerLogFileReader reader = new ServerLogFileReader(filename.ToString(), numLines); String[] readLines = StringToLines(reader.Read()); // All of file should be read Assert.AreEqual(numLines, readLines.Length); for (int i = 0; i < readLines.Length; i++) { Assert.AreEqual(contentLines[i], readLines[i]); } }
public void ReadLessThanInFile() { const int numFileLines = 15; string[] contentLines = GenerateContentLines(numFileLines); SystemPath filename = tempDir.CreateTextFile("ReadLessThanInFile.log", LinesToString(contentLines)); const int numReadLines = 10; ServerLogFileReader reader = new ServerLogFileReader(filename.ToString(), numReadLines); String[] readLines = StringToLines(reader.Read()); Assert.AreEqual(numReadLines, readLines.Length); for (int i = 0; i < readLines.Length; i++) { Assert.AreEqual(contentLines[numFileLines - numReadLines + i], readLines[i]); } }