示例#1
0
        public void TestAddCondition()
        {
            string firstPath            = Path.Combine(TestSupport.CreatedFilesDirectory, "first.xml");
            string secondPath           = Path.Combine(TestSupport.CreatedFilesDirectory, "second.xml");
            TestCasesRootContainer tcrc = new TestCasesRootContainer();

            tcrc.TestCasesRoot.Save(firstPath);
            SelectedValuesByConditionsAndActions selValues = new SelectedValuesByConditionsAndActions();

            selValues.CollectValues(tcrc.TestCasesRoot);
            selValues.Check(tcrc.TestCasesRoot);

            string newConditionName = "new condition " + DateTime.Now.ToString("F");
            int    conditionCount   = tcrc.TestCasesRoot.Conditions.Count;

            tcrc.TestCasesRoot.AppendCondition(ConditionObject.Create(newConditionName, new ObservableCollection <EnumValue>()
            {
                new EnumValue("new test", "new value")
            }));

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(tcrc.TestCasesRoot.Conditions.Count == conditionCount + 1);
            Assert.That(tcrc.TestCasesRoot.Conditions.Last().Name.Equals(newConditionName));
            Assert.That(tcrc.ConditionChangeCount == 2);
            Assert.That(tcrc.ActionChangeCount == 0);
            selValues.AppendCondition(tcrc.TestCasesRoot.TestCases.Count);
            selValues.Check(tcrc.TestCasesRoot);


            tcrc.TestCasesRoot.Save(secondPath);
            // only for manual check of testcase
            //TestSupport.CompareFile(firstPath, secondPath);
        }
示例#2
0
        public void TestActionMove(Move move, int index)
        {
            string firstPath            = Path.Combine(TestSupport.CreatedFilesDirectory, move + "_" + index + "_first.xml");
            string secondPath           = Path.Combine(TestSupport.CreatedFilesDirectory, move + "_" + index + "_second.xml");
            TestCasesRootContainer tcrc = new TestCasesRootContainer();

            SaveConditionsOrActions(tcrc.TestCasesRoot.Actions, firstPath);
            SelectedValuesByConditionsAndActions selValues = new SelectedValuesByConditionsAndActions();

            selValues.CollectValues(tcrc.TestCasesRoot);
            selValues.Check(tcrc.TestCasesRoot);

            if (move == Move.Up)
            {
                tcrc.TestCasesRoot.MoveActionUp(index);
            }
            else
            {
                tcrc.TestCasesRoot.MoveActionDown(index);
            }

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(tcrc.TestCasesRoot.Actions.Count == 3);
            Assert.That(tcrc.TestCasesRoot.Conditions.Count == 3);
            Assert.That(tcrc.ConditionChangeCount == 0);
            Assert.That(tcrc.ActionChangeCount == 2);
            selValues.Check(tcrc.TestCasesRoot);

            SaveConditionsOrActions(tcrc.TestCasesRoot.Actions, secondPath);
            // only for manual check of testcase
            //TestSupport.CompareFile(firstPath, secondPath);
        }
示例#3
0
        public void TestDeleteAction(DeletePosition deletePosition)
        {
            string firstPath            = Path.Combine(TestSupport.CreatedFilesDirectory, "first.xml");
            string secondPath           = Path.Combine(TestSupport.CreatedFilesDirectory, "second.xml");
            TestCasesRootContainer tcrc = new TestCasesRootContainer();

            tcrc.TestCasesRoot.Save(firstPath);
            SelectedValuesByConditionsAndActions selValues = new SelectedValuesByConditionsAndActions();

            selValues.CollectValues(tcrc.TestCasesRoot);
            selValues.Check(tcrc.TestCasesRoot);

            int indexWhereToDelete = TestUtils.CalculateIndex(tcrc.TestCasesRoot.Actions, deletePosition);
            int actionCount        = tcrc.TestCasesRoot.Actions.Count;

            tcrc.TestCasesRoot.DeleteActionAt(indexWhereToDelete);

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(actionCount == 3); // adjust last testcase on failue
            Assert.That(tcrc.TestCasesRoot.Actions.Count == actionCount - 1);
            Assert.That(tcrc.ConditionChangeCount == 0);
            Assert.That(tcrc.ActionChangeCount == 2);
            selValues.DeleteAction(deletePosition);
            selValues.Check(tcrc.TestCasesRoot);

            tcrc.TestCasesRoot.Save(secondPath);
            // only for manual check of testcase
            //TestSupport.CompareFile(firstPath, secondPath);
        }
示例#4
0
        public void TestInsertAction(InsertPosition insertPosition)
        {
            string firstPath            = Path.Combine(TestSupport.CreatedFilesDirectory, "first.xml");
            string secondPath           = Path.Combine(TestSupport.CreatedFilesDirectory, "second.xml");
            TestCasesRootContainer tcrc = new TestCasesRootContainer();

            tcrc.TestCasesRoot.Save(firstPath);
            SelectedValuesByConditionsAndActions selValues = new SelectedValuesByConditionsAndActions();

            selValues.CollectValues(tcrc.TestCasesRoot);
            selValues.Check(tcrc.TestCasesRoot);

            int    indexWhereToInsert = TestUtils.CalculateIndex(tcrc.TestCasesRoot.Conditions, insertPosition);
            string newActionName      = "new action" + DateTime.Now.ToString("F");
            int    actionCount        = tcrc.TestCasesRoot.Actions.Count;

            tcrc.TestCasesRoot.InsertAction(indexWhereToInsert, ActionObject.Create(newActionName, new ObservableCollection <EnumValue>()
            {
                new EnumValue("new test", "new value")
            }));

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(actionCount == 3); // adjust last testcase on failue
            Assert.That(tcrc.TestCasesRoot.Actions.Count == actionCount + 1);
            Assert.That(tcrc.TestCasesRoot.Actions[indexWhereToInsert].Name.Equals(newActionName));
            Assert.That(tcrc.ConditionChangeCount == 0);
            Assert.That(tcrc.ActionChangeCount == 2);
            selValues.InsertAction(insertPosition, tcrc.TestCasesRoot.TestCases.Count);
            selValues.Check(tcrc.TestCasesRoot);

            tcrc.TestCasesRoot.Save(secondPath);
            // only for manual check of testcase
            //TestSupport.CompareFile(firstPath, secondPath);
        }
        void SaveTestCasesDisplayOrder(TestCasesRootContainer tcrc, string path)
        {
            StringBuilder sb = new StringBuilder();

            foreach (TestCase testCase in tcrc.TestCasesRoot.TestCases.OrderBy(tc => tc.DisplayIndex))
            {
                sb.AppendFormat("{0} di={1}", testCase.Name, testCase.DisplayIndex).AppendLine();
            }
            File.WriteAllText(path, sb.ToString());
        }
        public void TestDeleteAndAddTestCase(AddRowsTest.DeletePosition deletePosition, int deleteCount, AddRowsTest.InsertPosition insertPosition, int addCount)
        {
            string firstPath            = Path.Combine(TestSupport.CreatedFilesDirectory, "first.xml");
            string secondPath           = Path.Combine(TestSupport.CreatedFilesDirectory, "second.xml");
            TestCasesRootContainer tcrc = new TestCasesRootContainer();

            tcrc.TestCasesRoot.Save(firstPath);
            SelectedValuesByTestCases selValues = new SelectedValuesByTestCases();

            selValues.CollectValues(tcrc.TestCasesRoot);
            selValues.Check(tcrc.TestCasesRoot);

            int testCaseCount = tcrc.TestCasesRoot.TestCases.Count;

            for (int idx = 0; idx < deleteCount; idx++)
            {
                int      indexWhereToDelete = TestUtils.CalculateIndex(tcrc.TestCasesRoot.TestCases, deletePosition);
                TestCase deletedTestCase    = tcrc.TestCasesRoot.TestCases[indexWhereToDelete];
                tcrc.TestCasesRoot.DeleteTestCaseAt(indexWhereToDelete);
                selValues.DeleteTestCase(deletedTestCase, tcrc.TestCasesRoot);
            }

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(tcrc.TestCasesRoot.TestCases.Count == testCaseCount - deleteCount);
            Assert.That(tcrc.ConditionChangeCount == deleteCount * 2);
            Assert.That(tcrc.ActionChangeCount == deleteCount * 2);
            selValues.Check(tcrc.TestCasesRoot);

            testCaseCount = tcrc.TestCasesRoot.TestCases.Count;
            for (int idx = 0; idx < addCount; idx++)
            {
                int      indexWhereToInsert = TestUtils.CalculateIndex(tcrc.TestCasesRoot.TestCases, insertPosition);
                TestCase newTestCase        = tcrc.TestCasesRoot.InsertTestCase(indexWhereToInsert);
                string   testCaseId         = "new test case " + DateTime.Now.ToString("F");
                newTestCase.TestProperty = testCaseId;
                selValues.AppendTestCase(newTestCase, tcrc.TestCasesRoot);
                Assert.That(tcrc.TestCasesRoot.TestCases[indexWhereToInsert].TestProperty.Equals(testCaseId));
            }

            TestUtils.CheckTestCasesAndConditionsAndActions(tcrc.TestCasesRoot);
            Assert.That(tcrc.TestCasesRoot.TestCases.Count == testCaseCount + addCount);
            Assert.That(tcrc.ConditionChangeCount == (deleteCount + addCount) * 2);
            Assert.That(tcrc.ActionChangeCount == (deleteCount + addCount) * 2);
            selValues.Check(tcrc.TestCasesRoot);

            tcrc.TestCasesRoot.Save(secondPath);
            // only for manual check of testcase
            //TestSupport.CompareFile(firstPath, secondPath);
        }
        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 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);
        }