/// <summary>
        /// Sets the "Value" attribute to the specified value, whether or not the attribute already exists
        /// </summary>
        /// <param name="element"></param>
        /// <param name="result"></param>
        private void SetValueAttribute(XElement element, CheckConstants.StepResults result)
        {
            XAttribute checkStepStateAttribute = element.Attribute(DataStringConstants.AttributeNames.Value);

            if (null == checkStepStateAttribute)
            {
                element.Add(new XAttribute(DataStringConstants.AttributeNames.Value, result.ToString()));
            }
            else
            {
                checkStepStateAttribute.Value = result.ToString();
            }
        }
        public void SetCurrentStepResult(CheckConstants.StepResults result, int msTimeResult)
        {
            // Due to exceptions not propagating past the invocation of the check method,
            //  use this property to prevent the step from looking like a "Pass."
            // This would normally apply at the check step that is the root method call.
            if ((result == CheckConstants.StepResults.Pass) && (this.FailInitiatedInCheck))
            {
                // override the "Pass" with a "Fail" because the check is failing
                result = CheckConstants.StepResults.Fail;
            }

            lock (m_lockObjectForStepRecords)
            {
                SetTimeElapsedAttribute(m_currentStep, msTimeResult);

                // Set the nodes unless the case of "Fail." In that case, set nodes to "Fail recursively, so do the Fail in
                //  the below block and just once.
                if (result != CheckConstants.StepResults.Fail)
                {
                    SetValueAttribute(m_currentStep, result);
                }
                else
                {
                    // The current step is set to "Fail" with this code block, and
                    // the following code sets all the blocked steps to "Blocked" if needed, i.e. if the check is failing
                    if ((!attributesForFailedAndBlockedStepsHaveBeenSet) && (result == CheckConstants.StepResults.Fail))
                    {
                        // Given the locking, this is the first "Fail" step
                        attributesForFailedAndBlockedStepsHaveBeenSet = true;
                        Stack <string> tempReversedStack = new Stack <string>();

                        XElement checkStepRootFinder = m_currentStep;

                        // find the node that is ancestor to all of the steps
                        while (checkStepRootFinder.Name == DataStringConstants.ElementNames.CheckStepInformation)
                        {
                            SetValueAttribute(checkStepRootFinder, result);
                            tempReversedStack.Push(
                                checkStepRootFinder.Attribute(DataStringConstants.AttributeNames.Name).Value);

                            if (checkStepRootFinder.Parent == null)
                            {
                                // Break out of the loop. This can happen if this context is a subcheck
                                break;
                            }
                            else
                            {
                                checkStepRootFinder = checkStepRootFinder.Parent;
                            }
                        }

                        var allElementsInDocumentOrder       = checkStepRootFinder.Descendants();
                        HashSet <XElement> followingElements = new HashSet <XElement>();

                        // find all steps that follow the current check step
                        foreach (XElement currentElement in allElementsInDocumentOrder)
                        {
                            if (currentElement.IsAfter((XNode)m_currentStep))
                            {
                                followingElements.Add(currentElement);
                            }
                        }

                        // Set all these steps as "Blocked" unless they already have a status set with the "Value" attribute
                        foreach (XElement element in followingElements)
                        {
                            if (element.Attribute(DataStringConstants.AttributeNames.Value) == null)
                            {
                                element.SetAttributeValue(
                                    DataStringConstants.AttributeNames.Value,
                                    CheckConstants.StepResults.Blocked);
                            }
                        }
                    }
                }
            }
        }