public GlobalView(TCFContent tcf) { InitializeComponent(); preIncludeTextBox.Text = tcf.PreIncludeCode.Text; postIncludeTextBox.Text = tcf.PostIncludeCode.Text; foreach (TCFVariable variable in tcf.UserGlobalVariables) { ListViewItem item = new ListViewItem(variable.Name); item.SubItems.Add(variable.Type); item.SubItems.Add(variable.Value); globalVariableList.Items.Add(item); } }
private static void ReadTestCase(StreamReader instream, TCFContent tcf, ref int lineNum) { TCFTestCase testCase = new TCFTestCase(); testCase.LineNumber = lineNum; string line; while (!(line = instream.ReadLine().Trim()).StartsWith(TCFTags.TestCaseEnd)) { lineNum++; if (line.StartsWith(TCFProperties.Procedure)) { testCase.ProcedureName = line.Substring(TCFProperties.Procedure.Length); } else if (line.StartsWith(TCFProperties.Description)) { testCase.Description.LineNumber = lineNum; testCase.Description.Text = line.Substring(TCFProperties.Description.Length); } else if (line.StartsWith(TCFTags.TestCaseDocumentBegin)) { testCase.Documentation.LineNumber = lineNum; ReadTestCaseDocument(instream, testCase, ref lineNum); } else if (line.StartsWith(TCFTags.StubBegin)) { ReadStub(instream, testCase, ref lineNum); } else if (line.StartsWith(TCFTags.VariableBegin)) { ReadVariableIO(instream, testCase, ref lineNum); } else if (line.StartsWith(TCFTags.DeclarationBegin)) { testCase.Declarations.LineNumber = lineNum; testCase.Declarations.Text = GetContextBlock(instream, TCFTags.DeclarationEnd, ref lineNum); } else if (line.StartsWith(TCFTags.GlobalDeclarationsBegin)) { testCase.GlobalDeclarations.LineNumber = lineNum; testCase.GlobalDeclarations.Text = GetContextBlock(instream, TCFTags.GlobalDeclarationsEnd, ref lineNum); } else if (line.StartsWith(TCFTags.InitCodeBegin)) { testCase.InitializationCode.LineNumber = lineNum; testCase.InitializationCode.Text = GetContextBlock(instream, TCFTags.InitCodeEnd, ref lineNum); } else if (line.StartsWith(TCFTags.CleanupCodeBegin)) { testCase.CleanupCode.LineNumber = lineNum; testCase.CleanupCode.Text = GetContextBlock(instream, TCFTags.CleanupCodeEnd, ref lineNum); } } lineNum++; tcf.TestCases.Add(testCase); }
private static void ReadGlobalVariable(StreamReader instream, TCFContent tcf, ref int lineNum) { TCFVariable variable = new TCFVariable(); string line; variable.LineNumber = lineNum; while (!(line = instream.ReadLine().Trim()).StartsWith(TCFTags.GlobalEnd)) { lineNum++; if (line.StartsWith(TCFProperties.Name)) { variable.Name = line.Substring(TCFProperties.Name.Length); } else if (line.StartsWith(TCFProperties.Type)) { variable.Type = line.Substring(TCFProperties.Type.Length); } else if (line.StartsWith(TCFProperties.Value)) { variable.Value = line.Substring(TCFProperties.Value.Length); } } lineNum++; tcf.UserGlobalVariables.Add(variable); }
/// <summary> /// Read and parse a tcf file. /// </summary> /// <param name="path">The path to the tcf file</param> /// <returns>An TCFContent instance that stores the data in the tcf file</returns> public static TCFContent Read(string path) { TCFContent tcf = new TCFContent(); string line; int lineNum = 0; using (StreamReader instream = new StreamReader(path)) { while ((line = instream.ReadLine()) != null) { lineNum++; line = line.Trim(); if (line.StartsWith(TCFTags.TestCaseBegin)) { ReadTestCase(instream, tcf, ref lineNum); } else if (line.StartsWith(TCFTags.GlobalBegin)) { ReadGlobalVariable(instream, tcf, ref lineNum); } } lineNum++; } return tcf; }
public TCFViewer() { InitializeComponent(); tcf = new TCFContent(); currentSeq = -1; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { tcf = TCFReader.Read(openFileDialog.FileName); } Render(); }