Exemplo n.º 1
0
 private void FormatHasSteps(IHasSteps hasSteps, StringBuilder result)
 {
     foreach (var step in hasSteps.Steps)
     {
         FormatStep(step, result);
     }
 }
Exemplo n.º 2
0
        private static void AddBackground(IHasSteps background, ITestBase testCase)
        {
            if (background == null)
            {
                return;
            }

            StepHelper.AddSteps(testCase, background.Steps, SyncUtil.BackgroundPrefix, false);
        }
Exemplo n.º 3
0
        private static void SaveChanges(ITestManagementTeamProject teamProject, IHasSteps background, ITestCase testCase,
                                        ScenarioDefinition scenarioDefinition, string hash, string area, ICollection <Tag> tags,
                                        IEnumerable <TestCaseField> fieldsCollection)
        {
            var isUpdate = true;

            if (testCase == null)
            {
                try
                {
                    testCase = CreateTestCase(teamProject, scenarioDefinition, fieldsCollection);
                }
                catch (InvalidFieldValueException exception)
                {
                    Logger.Error(
                        ResourceStrings.DECORATION,
                        string.Format(CultureInfo.InvariantCulture, SyncUtil.ABORTED_MESSAGE, exception.Message));
                    return;
                }

                isUpdate = false;
            }

            testCase.WorkItem.Fields[SyncUtil.VersionField].Value = hash;
            UpdateTestCaseArea(testCase, area);
            TestCaseHelper.UpdateTestcase(background, scenarioDefinition, testCase);
            if (!IsTestCaseValid(testCase))
            {
                Logger.Error(
                    ResourceStrings.DECORATION,
                    string.Format(
                        CultureInfo.InvariantCulture, SyncUtil.ABORTED_MESSAGE,
                        "Something is wrong, check the field values"));
                return;
            }

            SaveTestCase(testCase);
            if (!isUpdate)
            {
                var scenarioTags = GherkinUtils.GetTags(scenarioDefinition);
                var mtmIdTag     = scenarioTags.Last();
                tags.Add(
                    new Tag(
                        new Location(mtmIdTag.Location.Line, mtmIdTag.Location.Column + 1),
                        $"{SyncUtil.MtmTcLink}{testCase.Id}"));
                Logger.Info(ResourceStrings.DECORATION, $"{testCase.Id} is created");
                return;
            }

            Logger.Info(ResourceStrings.DECORATION, $"{testCase.Id} is updated");
        }
Exemplo n.º 4
0
        internal static void UpdateTestcase(IHasSteps background, IHasSteps scenarioDefinition, ITestCase testCase)
        {
            var isScenarioOutline = scenarioDefinition is ScenarioOutline;

            AddBackground(background, testCase);
            StepHelper.AddSteps(testCase, scenarioDefinition?.Steps, "", isScenarioOutline);
            if (!isScenarioOutline)
            {
                return;
            }

            var scenarioOutline = (ScenarioOutline)scenarioDefinition;

            AddParameters(scenarioOutline, testCase);
        }
Exemplo n.º 5
0
 private void FormatHasSteps(IHasSteps hasSteps, StringBuilder result)
 {
     foreach (var step in hasSteps.Steps)
         FormatStep(step, result);
 }