//======================================================================== private void CheckerDone(object sender, RunWorkerCompletedEventArgs e) { if (e.Result != null) { session.Disconnect(); MessageBox.Show("Error Running File\n" + (string)e.Result, "Run Report", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } StatusUpdate(10, "Report Finished\nReading Results"); int repSeq = session.GetReportSequence(specfile.name, time); if (repSeq == -1) { MessageBox.Show("Couldn't Find Finished Report Sequence!"); Close(); return; } List <SymFile> reports = new List <SymFile>(); List <string> contents = new List <string>(); reports.Add(new SymFile(session.server, session.sym, repSeq.ToString(), DateTime.Now, 0, SymFile.Type.REPORT)); string listing = session.FileRead(reports[0]); reports[0].sequence = repSeq; reports[0].pages = 1; reports[0].title = "Batch Output for REPWRITER"; contents.Add(listing.Replace("\n", "\r\n")); Regex repReg = new Regex(@"Seq:\s+([0-9]{6})\s+Pages:\s+([0-9]+)\s+Title:\s+([^\n]+)\n"); Match match = repReg.Match(listing); while (match.Success) { listing = listing.Replace(match.Value, ""); SymFile currRep = new SymFile(session.server, session.sym, (int.Parse(match.Groups[1].Value)).ToString(), DateTime.Now, 0, SymFile.Type.REPORT); currRep.sequence = int.Parse(match.Groups[1].Value); currRep.pages = int.Parse(match.Groups[2].Value); currRep.title = match.Groups[3].Value; reports.Add(currRep); contents.Add(session.FileRead(currRep).Replace("\n", "\r\n")); //MessageBox.Show('\"' + match.Groups[1].Value + "\"\n\"" + match.Groups[2].Value + "\"\n\"" + match.Groups[3].Value + '\"'); match = repReg.Match(listing); } session.Disconnect(); frmReport viewer = new frmReport(specfile.sym, specfile.name, reports, contents, server, originalInst, false); viewer.Show(); Close(); }
public void FileRead_NoSuchFile_ThrowFileNotFound() { var mockSocket = Substitute.For <ISymSocket>(); mockSocket.ReadCommand().Returns(new SymCommand("Read", new Dictionary <string, string> { { "Status", "No such file or directory" } })); var session = new SymSession(mockSocket, 10); Assert.Throws <FileNotFoundException>(() => session.FileRead("002356", FileType.Report)); }
public void FileRead_LongFileName_ThrowException() { var mockSocket = Substitute.For <ISymSocket>(); mockSocket.ReadCommand().Returns(new SymCommand("Read", new Dictionary <string, string> { { "Status", "" } })); var session = new SymSession(mockSocket, 10); Assert.Throws <Exception>(() => session.FileRead("ReallyReallReallyReallyLongFileName", FileType.Report), "Filename Too Long"); }
public void FileRead_BlankReport_ReturnsEmptyString() { var mockSocket = Substitute.For <ISymSocket>(); mockSocket.ReadCommand() .Returns(new SymCommand("Read", new Dictionary <string, string> { { "Status", "Cannot view a blank report" } })); var session = new SymSession(mockSocket, 10); string result = session.FileRead("002356", FileType.Report); result.Should().BeNullOrEmpty(); }
private void FileReadTest(string fileName, FileType fileType) { string contents = _session.FileRead(fileName, fileType); LogResponse(contents); }
public void FileRead_NoSuchFile_ThrowFileNotFound() { var mockSocket = Substitute.For<ISymSocket>(); mockSocket.ReadCommand().Returns(new SymCommand("Read", new Dictionary<string, string> {{"Status", "No such file or directory"}})); var session = new SymSession(mockSocket, 10); Assert.Throws<FileNotFoundException>(() => session.FileRead("002356", FileType.Report)); }
public void FileRead_LongFileName_ThrowException() { var mockSocket = Substitute.For<ISymSocket>(); mockSocket.ReadCommand().Returns(new SymCommand("Read", new Dictionary<string, string> {{"Status", ""}})); var session = new SymSession(mockSocket, 10); Assert.Throws<Exception>(() => session.FileRead("ReallyReallReallyReallyLongFileName", FileType.Report), "Filename Too Long"); }
public void FileRead_BlankReport_ReturnsEmptyString() { var mockSocket = Substitute.For<ISymSocket>(); mockSocket.ReadCommand() .Returns(new SymCommand("Read", new Dictionary<string, string> {{"Status", "Cannot view a blank report"}})); var session = new SymSession(mockSocket, 10); string result = session.FileRead("002356", FileType.Report); result.Should().BeNullOrEmpty(); }