//--------------------------------------------------------------------- private void TryParse(string filename, int errorLineNum) { try { reader = OpenFile(filename); // This method is only called on bad files, so we expect the // statement below to throw an exception. Since we knowingly // ignore the variable "landUses", disable the CS0219 warning // "The variable '...' is assigned but its value is never used'. #pragma warning disable 0219 IList <LandUse> landUses = parser.Parse(reader); #pragma warning restore 0219 } catch (System.Exception e) { Data.Output.WriteLine(e.Message.Replace(Data.Directory, Data.DirPlaceholder)); LineReaderException lrExc = e as LineReaderException; if (lrExc != null) { Assert.AreEqual(errorLineNum, lrExc.LineNumber); } Data.Output.WriteLine(); throw; } finally { reader.Close(); } }
//--------------------------------------------------------------------- private void TryParseTable(int expectedLineNum, params string[] lines) { reader = MakeTableReader(lines); try { ParseResult[] result = tableParser.Parse(reader); } catch (System.Exception e) { Data.Output.WriteLine(e.Message); LineReaderException lrExc = e as LineReaderException; if (lrExc != null) { Assert.AreEqual(expectedLineNum, lrExc.LineNumber); } throw; } }
//--------------------------------------------------------------------- private void TryParse(string filename, int errorLineNum) { try { reader = OpenFile(filename); IDataset dataset = parser.Parse(reader); } catch (System.Exception e) { Data.Output.WriteLine(e.Message); LineReaderException lrExc = e as LineReaderException; if (lrExc != null) { Assert.AreEqual(errorLineNum, lrExc.LineNumber); } throw; } finally { reader.Close(); } }
//--------------------------------------------------------------------- private void TryParse(string filename, int errorLineNum) { try { reader = OpenFile(filename); Scenario scenario = parser.Parse(reader); } catch (System.Exception e) { Data.Output.WriteLine(); Data.Output.WriteLine(e.Message.Replace(Data.Directory, Data.DirPlaceholder)); LineReaderException lrExc = e as LineReaderException; if (lrExc != null) { Assert.AreEqual(errorLineNum, lrExc.LineNumber); } throw; } finally { reader.Close(); } }
//--------------------------------------------------------------------- private void TryParse(string filename) { int?errorLineNum = Testing.FindErrorMarker(MakeInputPath(filename)); try { reader = OpenFile(filename); IParameterDataset dataset = parser.Parse(reader); } catch (System.Exception e) { Data.Output.WriteLine(); Data.Output.WriteLine(e.Message.Replace(Data.Directory, Data.DirPlaceholder)); LineReaderException lrExc = e as LineReaderException; if (lrExc != null && errorLineNum.HasValue) { Assert.AreEqual(errorLineNum.Value, lrExc.LineNumber); } throw; } finally { reader.Close(); } }