示例#1
0
        /// <summary>
        /// Write out the TOP part of sql select statement
        /// It basically writes TOP (X) [WITH TIES].
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="sqlGenerator"></param>
        public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
        {
            if (SkipCount != null)
            {
                writer.WriteLine();
                writer.Write("offset ");
                writer.Write(SkipCount.GetInt(sqlGenerator) + 1);
                writer.Write(" ");
            }

            if (TopCount != null)
            {
                writer.WriteLine();
                writer.Write("fetch ");
                if (SkipCount != null)
                {
                    writer.Write("next ");
                }
                else
                {
                    writer.Write("first ");
                }
                writer.Write(TopCount.GetInt(sqlGenerator));
                writer.Write(" rows only ");
            }
        }
示例#2
0
        public void Setup(ActionSet actionSet)
        {
            if (IsSetup)
            {
                return;
            }
            IsSetup = true;

            SkipCount  = Rule.DeltinScript.VarCollection.Assign("continueSkip", Rule.IsGlobal, true);
            TempHolder = Rule.DeltinScript.VarCollection.Assign("continueSkipTemp", Rule.IsGlobal, true);

            A_SkipIf skipAction = Element.Part <A_SkipIf>
                                  (
                // Condition
                Element.Part <V_Compare>(SkipCount.GetVariable(), EnumData.GetEnumValue(Operators.Equal), new V_Number(0)),
                // Number of actions
                new V_Number(3)
                                  );

            Skipper           = new SkipStartMarker(actionSet);
            Skipper.SkipCount = TempHolder.GetVariable();

            IActionList[] actions = ArrayBuilder <IActionList> .Build(
                new ALAction(A_Wait.MinimumWait),
                new ALAction(skipAction),
                new ALAction(TempHolder.SetVariable((Element)SkipCount.GetVariable())[0]),
                new ALAction(SkipCount.SetVariable(0)[0]),
                Skipper
                );

            Rule.Actions.InsertRange(0, actions);
        }
示例#3
0
        /// <summary>
        /// Adds the XML representation of the result as a child of the
        /// supplied parent node..
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">If true, descendant results are included</param>
        /// <returns></returns>
        public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive)
        {
            // A result node looks like a test node with extra info added
            XmlNode thisNode = this.Test.AddToXml(parentNode, false);

            thisNode.AddAttribute("result", ResultState.Status.ToString());
            if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString())
            {
                thisNode.AddAttribute("label", ResultState.Label);
            }

            thisNode.AddAttribute("start-time", StartTime.ToString("u"));
            thisNode.AddAttribute("end-time", EndTime.ToString("u"));
            thisNode.AddAttribute("duration", Duration.TotalSeconds.ToString("0.000000", NumberFormatInfo.InvariantInfo));

            if (this.Test is TestSuite)
            {
                thisNode.AddAttribute("total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString());
                thisNode.AddAttribute("passed", PassCount.ToString());
                thisNode.AddAttribute("failed", FailCount.ToString());
                thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString());
                thisNode.AddAttribute("skipped", SkipCount.ToString());
            }

            thisNode.AddAttribute("asserts", this.AssertCount.ToString());

            switch (ResultState.Status)
            {
            case TestStatus.Failed:
                AddFailureElement(thisNode);
                break;

            case TestStatus.Skipped:
                AddReasonElement(thisNode);
                break;

            case TestStatus.Passed:
            case TestStatus.Inconclusive:
                if (this.Message != null)
                {
                    AddReasonElement(thisNode);
                }
                break;
            }

            if (recursive && HasChildren)
            {
                foreach (TestResult child in Children)
                {
                    child.AddToXml(thisNode, recursive);
                }
            }

            return(thisNode);
        }
示例#4
0
        /// <summary>
        /// Adds the XML representation of the result as a child of the
        /// supplied parent node..
        /// </summary>
        /// <param name="parentNode">The parent node.</param>
        /// <param name="recursive">If true, descendant results are included</param>
        /// <returns></returns>
        public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive)
        {
            // A result node looks like a test node with extra info added
            XmlNode thisNode = this.test.AddToXml(parentNode, false);

            XmlHelper.AddAttribute(thisNode, "result", ResultState.Status.ToString());
            if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString())
            {
                XmlHelper.AddAttribute(thisNode, "label", ResultState.Label);
            }

            XmlHelper.AddAttribute(thisNode, "time", this.Time.ToString("0.000", System.Globalization.CultureInfo.InvariantCulture));

            if (this.test is TestSuite)
            {
                XmlHelper.AddAttribute(thisNode, "total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString());
                XmlHelper.AddAttribute(thisNode, "passed", PassCount.ToString());
                XmlHelper.AddAttribute(thisNode, "failed", FailCount.ToString());
                XmlHelper.AddAttribute(thisNode, "inconclusive", InconclusiveCount.ToString());
                XmlHelper.AddAttribute(thisNode, "skipped", SkipCount.ToString());
            }

            XmlHelper.AddAttribute(thisNode, "asserts", this.AssertCount.ToString());

            switch (ResultState.Status)
            {
            case TestStatus.Failed:
                AddFailureElement(thisNode);
                break;

            case TestStatus.Skipped:
                AddReasonElement(thisNode);
                break;

            case TestStatus.Passed:
                break;

            case TestStatus.Inconclusive:
                break;
            }

            if (recursive && HasChildren)
            {
                foreach (TestResult child in Children)
                {
                    child.AddToXml(thisNode, recursive);
                }
            }

            return(thisNode);
        }
示例#5
0
        private void Pop()
        {
            Writer w = _writerStack.Pop();

            w.XmlWriter.WriteRaw(w.Content.ToString());
            w.XmlWriter.WriteEndElement();
            w.XmlWriter.Flush();
            if (_writerStack.Count > 1)
            {
                _writerStack.Peek().Content.AppendLine(w.TextWriter.ToString());
            }
            else if (_writerStack.Count > 0)
            {
                CurrentWriter.WriteAttributeString("total", (PassCount + FailCount + SkipCount).ToString());
                CurrentWriter.WriteAttributeString("failures", FailCount.ToString());
                CurrentWriter.WriteAttributeString("not-run", SkipCount.ToString());
                StringBuilder environment = new StringBuilder();
                environment.AppendLine("environment");
                environment.AppendFormat("clr-version: {0}\n", Environment.Version.ToString());
                environment.AppendFormat("os-version: {0}\n", Environment.OSVersion.ToString());
                environment.AppendFormat("cwd: {0}\n", Environment.CurrentDirectory);
                environment.AppendFormat("machine-name: {0}\n", Environment.MachineName);
                environment.AppendFormat("user: {0}\n", Environment.UserName);
                environment.AppendFormat("user-domain: {0}\n", Environment.UserDomainName);
                environment.AppendLine("culture-info");
                environment.AppendFormat("current_culture: {0}\n", CultureInfo.CurrentCulture.Name);
                environment.AppendFormat("current_uiculture: {0}\n", CultureInfo.CurrentUICulture.Name);
                CurrentWriter.WriteComment(environment.ToString());
                _writerStack.Peek().Content.AppendLine(w.TextWriter.ToString());
                Pop();
            }
            else
            {
                _writer.WriteLine(w.TextWriter.ToString());
                _writer.Flush();
            }
            Debug.IndentLevel--;
            Debug.WriteLine("", "End");
        }
示例#6
0
        public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive)
        {
            XmlNode xmlNode = test.AddToXml(parentNode, recursive: false);

            XmlHelper.AddAttribute(xmlNode, "result", ResultState.Status.ToString());
            if (ResultState.Label != string.Empty)
            {
                XmlHelper.AddAttribute(xmlNode, "label", ResultState.Label);
            }
            XmlHelper.AddAttribute(xmlNode, "time", Time.ToString("0.000", CultureInfo.InvariantCulture));
            if (test is TestSuite)
            {
                XmlHelper.AddAttribute(xmlNode, "total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString());
                XmlHelper.AddAttribute(xmlNode, "passed", PassCount.ToString());
                XmlHelper.AddAttribute(xmlNode, "failed", FailCount.ToString());
                XmlHelper.AddAttribute(xmlNode, "inconclusive", InconclusiveCount.ToString());
                XmlHelper.AddAttribute(xmlNode, "skipped", SkipCount.ToString());
            }
            XmlHelper.AddAttribute(xmlNode, "asserts", AssertCount.ToString());
            switch (ResultState.Status)
            {
            case TestStatus.Failed:
                AddFailureElement(xmlNode);
                break;

            case TestStatus.Skipped:
                AddReasonElement(xmlNode);
                break;
            }
            if (recursive && HasChildren)
            {
                foreach (TestResult child in Children)
                {
                    child.AddToXml(xmlNode, recursive);
                }
            }
            return(xmlNode);
        }
示例#7
0
        public virtual TNode AddToXml(TNode parentNode, bool recursive)
        {
            // A result node looks like a test node with extra info added
            TNode thisNode = Test.AddToXml(parentNode, false);

            thisNode.AddAttribute("result", ResultState.Status.ToString());
            if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString())
            {
                thisNode.AddAttribute("label", ResultState.Label);
            }
            if (ResultState.Site != FailureSite.Test)
            {
                thisNode.AddAttribute("site", ResultState.Site.ToString());
            }

            thisNode.AddAttribute("start-time", StartTime.ToString("o"));
            thisNode.AddAttribute("end-time", EndTime.ToString("o"));
            thisNode.AddAttribute("duration", Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo));

            if (Test is TestSuite)
            {
                thisNode.AddAttribute("total", TotalCount.ToString());
                thisNode.AddAttribute("passed", PassCount.ToString());
                thisNode.AddAttribute("failed", FailCount.ToString());
                thisNode.AddAttribute("warnings", WarningCount.ToString());
                thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString());
                thisNode.AddAttribute("skipped", SkipCount.ToString());
            }

            thisNode.AddAttribute("asserts", AssertCount.ToString());

            switch (ResultState.Status)
            {
            case TestStatus.Failed:
                AddFailureElement(thisNode);
                break;

            case TestStatus.Skipped:
            case TestStatus.Passed:
            case TestStatus.Inconclusive:
            case TestStatus.Warning:
                if (Message != null && Message.Trim().Length > 0)
                {
                    TNode reasonNode = thisNode.AddElement("reason");
                    reasonNode.AddElementWithCDATA("message", Message);
                }
                break;
            }

            if (Output.Length > 0)
            {
                AddOutputElement(thisNode);
            }

            if (AssertionResults.Count > 0)
            {
                AddAssertionsElement(thisNode);
            }

            if (_testAttachments.Count > 0)
            {
                AddAttachmentsElement(thisNode);
            }

            if (recursive && HasChildren)
            {
                foreach (var child in Children)
                {
                    child.AddToXml(thisNode, recursive);
                }
            }

            return(thisNode);
        }
示例#8
0
 public override string ToString()
 {
     return(string.Format("limit {0},{1}", SkipCount.ToString(), TakeCount.ToString()));
 }
示例#9
0
 public void SetSkipCount(ActionSet actionSet, Element skipCount)
 {
     CheckSetup();
     actionSet.AddAction(SkipCount.SetVariable(skipCount));
 }