public static string RenderAssertions(bool before, int x)
        {
            StringBuilder assertions = new StringBuilder();
            List <RecordingAssertionData> Assertions = AutomationRecorder.RecordedActions[x].Assertions.FindAll(y => y.AssertionBeforeStep == (before ? true : false));

            for (int a = 0; a < Assertions.Count; a++)
            {
                assertions.AppendLine("<div class='code_line'>");
                RecordingAssertionData assertion = Assertions[a];
                if (assertion.Type == AssertionType.FreeForm)
                {
                    assertions.AppendLine(string.Format("<span class='object_declaration'>Q</span>.assert.{0}();", assertion.AssertionArgument));
                }
                else
                {
                    string assertTypeCode     = string.Empty;
                    string assertArgumentCode = string.Empty;

                    switch (assertion.Type)
                    {
                    case AssertionType.IsTrue:
                        assertTypeCode     = "IsTrue";
                        assertArgumentCode = string.Format("currentObject.Text.Contains{0}(<span class='string_text'>\"{1}\"</span>)", assertion.AssertionIsTrue == AssertionIsTrue.TextEquals ? string.Empty : "OrEquals", assertion.AssertionArgument);
                        break;

                    case AssertionType.IsInteractable:
                        assertTypeCode     = "IsActiveVisibleAndInteractable";
                        assertArgumentCode = "currentObject";
                        break;

                    case AssertionType.NotNull:
                        assertTypeCode     = "NotNull";
                        assertArgumentCode = "currentObject";
                        break;
                    }

                    assertions.AppendLine(string.Format("<div class='code_line'><span class='value'>yield return StartCoroutine</span>(<span class='object_declaration'>Q</span>.assert.{0}({1}, <span class='string_text'>\"{2}\"</span>{3}{4}));</div>", assertTypeCode, assertArgumentCode, assertion.AssertionMessage, assertion.FailureContext != FailureContext.Default ? string.Format(", FailureContext.{0}", assertion.FailureContext) : string.Empty, assertion.IsReverseCondition ? ", true" : string.Empty));
                }
                assertions.AppendLine("</div>");
            }

            if (!before && x == AutomationRecorder.RecordedActions.Count - 1 && !_lastAddedStep.Contains("yield return"))
            {
                //The final line of test code in an enumerator must be a return statement.
                assertions.AppendLine("<div class='code_line'><span class='value'>yield return null</span>;</div>");
            }

            return(_lastAddedStep = assertions.ToString());
        }
 //Add existing assertion to step.
 public static void AddAssertionToActionId(int id, RecordingAssertionData assertion)
 {
     assertion.ID = CurrentAssertionID++;
     RecordedActions.Find(x => x.ID == id).Assertions.Add(assertion);
 }