public void ExpandTestcases(string fileName) { string testOutput = Path.Combine(TestSupport.CreatedFilesDirectory, fileName + ".Output.txt"); string source = Path.Combine(TestSupport.TestFilesDirectory, fileName); TestCasesRoot tcr = new TestCasesRoot(); tcr.Load(source); var statistics = tcr.CalculateStatistics(); ExpandTestCases expand = new ExpandTestCases(); var result = expand.Expand(tcr); StringBuilder sb = new StringBuilder(); sb.AppendLine("TestCases"); foreach (TestCase tc in tcr.TestCases) { DumpTestCase(sb, tc); sb.AppendLine(); } sb.AppendLine("expanded TestCases"); foreach (ITestCase tc in result) { DumpTestCase(sb, tc); sb.AppendLine(); } sb.AppendFormat("calculated {0,5} expandCount {1,5}", statistics.CoveredTestCases, result.Count); File.WriteAllText(testOutput, sb.ToString()); //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", testOutput); //Process.Start(info); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(testOutput))); Assert.That(statistics.CoveredTestCases == result.Count); }
public void FirstHtmlContentFromTemplateResourceEmptyProject() { string resultPath = Path.Combine(TestSupport.CreatedFilesDirectory, "output.html"); TestCasesRoot tcRoot = new TestCasesRoot(); var result = tcRoot.GenerateFromTemplateString(DecisionTableCreator.Templates.Resources.HtmlTemplate); File.WriteAllText(resultPath, result.GeneratedContent); Assert.That(!result.ErrorListener.ErrorReported); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(resultPath))); }
public void CreateHtmlTableTest() { string templPath = Path.Combine(TestSupport.TestFilesDirectory, "HtmlTemplate.stg"); string resultPath = Path.Combine(TestSupport.CreatedFilesDirectory, "output.htm"); TestCasesRoot tcRoot = TestCasesRoot.CreateSimpleTable(); var templResult = tcRoot.GenerateFromtemplate(templPath); File.WriteAllText(resultPath, templResult.GeneratedContent); Assert.That(!templResult.ErrorListener.ErrorReported); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(resultPath))); }
public void CustomErrorListenerTest(int idx, string fileName, bool errorsExpected) { string templatePath = Path.Combine(TestSupport.TestFilesDirectory, fileName); string outputPath = Path.Combine(TestSupport.CreatedFilesDirectory, "output" + idx + ".txt"); string errorsPath = Path.Combine(TestSupport.CreatedFilesDirectory, "errors" + idx + ".txt"); TestCasesRoot tcRoot = TestCasesRoot.CreateSimpleTable(); var output = tcRoot.GenerateFromTemplateString(File.ReadAllText(templatePath)); Assert.That(output.ErrorListener.ErrorReported == errorsExpected); File.WriteAllText(outputPath, output.GeneratedContent); File.WriteAllText(errorsPath, output.GetErrorList()); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(outputPath))); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(errorsPath))); }
public void LoadOldProjectFiles(int idx, string fileName) { string loadPath = Path.Combine(TestSupport.TestFilesDirectory, fileName); string savePath = Path.Combine(TestSupport.CreatedFilesDirectory, fileName); TestCasesRoot root = new TestCasesRoot(); root.Load(loadPath); root.Save(savePath); // only to view the diffrence TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.TestFilesDirectory, Path.GetFileName(savePath)); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(savePath))); //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", savePath); //Process.Start(info); }
public void Save100() { string savePath = Path.Combine(TestSupport.CreatedFilesDirectory, "Save.dtc"); TestCasesRoot root = TestCasesRoot.CreateSimpleTable(); root.Save(savePath); root.New(); root.Load(savePath); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(savePath))); //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", savePath); //Process.Start(info); }
public void TestAddTestCase() { string firstPath = Path.Combine(TestSupport.CreatedFilesDirectory, "first.xml"); string secondPath = Path.Combine(TestSupport.CreatedFilesDirectory, "second.xml"); TestCasesRootContainer tcrc = new TestCasesRootContainer(); TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot); tcrc.TestCasesRoot.TestCases[0].DisplayIndex = 3; tcrc.TestCasesRoot.TestCases[1].DisplayIndex = 4; tcrc.TestCasesRoot.TestCases[2].DisplayIndex = 6; tcrc.TestCasesRoot.TestCases[3].DisplayIndex = 1; tcrc.TestCasesRoot.TestCases[4].DisplayIndex = 5; tcrc.TestCasesRoot.TestCases[5].DisplayIndex = 2; SaveTestCasesDisplayOrder(tcrc, firstPath); SelectedValuesByTestCases selValues = new SelectedValuesByTestCases(); selValues.CollectValues(tcrc.TestCasesRoot); selValues.Check(tcrc.TestCasesRoot); int testCaseCount = tcrc.TestCasesRoot.TestCases.Count; TestCase newTestCase = tcrc.TestCasesRoot.InsertTestCase(-1); string testCaseId = "new test case " + DateTime.Now.ToString("F"); newTestCase.TestProperty = testCaseId; TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot); Assert.That(tcrc.TestCasesRoot.TestCases.Count == testCaseCount + 1); Assert.That(tcrc.TestCasesRoot.TestCases.Last().TestProperty.Equals(testCaseId)); Assert.That(tcrc.ConditionChangeCount == 2); Assert.That(tcrc.ActionChangeCount == 2); selValues.AppendTestCase(newTestCase, tcrc.TestCasesRoot); selValues.Check(tcrc.TestCasesRoot); SaveTestCasesDisplayOrder(tcrc, secondPath); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(firstPath))); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(secondPath))); // only for manual check of testcase //TestSupport.CompareFile(firstPath, secondPath); }
public void PrepareHtmlForClipboard() { string resultPath = Path.Combine(TestSupport.CreatedFilesDirectory, "output.txt"); string resultPathHtml = Path.Combine(TestSupport.CreatedFilesDirectory, "html.txt"); string resultPathFragment = Path.Combine(TestSupport.CreatedFilesDirectory, "fragment.txt"); TestCasesRoot tcRoot = TestCasesRoot.CreateSimpleTable(); var templResult = tcRoot.GenerateFromTemplateString(DecisionTableCreator.Templates.Resources.HtmlTemplate); PrepareForClipboard prepare = new PrepareForClipboard(); string result = prepare.Prepare(templResult.GeneratedContent); Assert.That(!templResult.ErrorListener.ErrorReported); File.WriteAllText(resultPath, result); File.WriteAllText(resultPathHtml, result.Substring(prepare.StartHtml, prepare.EndHtml - prepare.StartHtml)); File.WriteAllText(resultPathFragment, result.Substring(prepare.StartFragment, prepare.EndFragment - prepare.StartFragment)); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(resultPathHtml))); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(resultPathFragment))); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(resultPath))); }
public void TestDeleteTestCase(AddRowsTest.DeletePosition deletePosition) { string firstPath = Path.Combine(TestSupport.CreatedFilesDirectory, deletePosition + "_first.xml"); string secondPath = Path.Combine(TestSupport.CreatedFilesDirectory, deletePosition + "_second.xml"); TestCasesRootContainer tcrc = new TestCasesRootContainer(); tcrc.TestCasesRoot.TestCases[0].DisplayIndex = 3; tcrc.TestCasesRoot.TestCases[1].DisplayIndex = 4; tcrc.TestCasesRoot.TestCases[2].DisplayIndex = 6; tcrc.TestCasesRoot.TestCases[3].DisplayIndex = 1; tcrc.TestCasesRoot.TestCases[4].DisplayIndex = 5; tcrc.TestCasesRoot.TestCases[5].DisplayIndex = 2; SaveTestCasesDisplayOrder(tcrc, firstPath); SelectedValuesByTestCases selValues = new SelectedValuesByTestCases(); selValues.CollectValues(tcrc.TestCasesRoot); selValues.Check(tcrc.TestCasesRoot); int indexWhereToDelete = TestUtils.CalculateIndex(tcrc.TestCasesRoot.TestCases, deletePosition); int testCaseCount = tcrc.TestCasesRoot.TestCases.Count; TestCase deletedTestCase = tcrc.TestCasesRoot.DeleteTestCaseAt(indexWhereToDelete); TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot); Assert.That(tcrc.TestCasesRoot.TestCases.Count == testCaseCount - 1); Assert.That(tcrc.ConditionChangeCount == 2); Assert.That(tcrc.ActionChangeCount == 2); selValues.DeleteTestCase(deletedTestCase, tcrc.TestCasesRoot); selValues.Check(tcrc.TestCasesRoot); SaveTestCasesDisplayOrder(tcrc, secondPath); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(firstPath))); Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(secondPath))); // only for manual check of testcase //TestSupport.CompareFile(firstPath, secondPath); }