当前位置: 首页>>代码示例>>C#>>正文


C# Result.Error方法代码示例

本文整理汇总了C#中System.Result.Error方法的典型用法代码示例。如果您正苦于以下问题:C# Result.Error方法的具体用法?C# Result.Error怎么用?C# Result.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Result的用法示例。


在下文中一共展示了Result.Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildRowNode

        public List<XmlNode> BuildRowNode(ResultHolder dataHolder, Result result)
        {
            List<XmlNode> resultNodes = new List<XmlNode>();

            foreach (ResultHolder.RowResult rowResult in dataHolder.singleRows)
            {
                string partPassed = ResultType.PASS;
                XmlElement resultNode = doc.CreateElement("result");
                resultNode.SetAttribute("status", ResultType.PASS);
                if (!dataHolder.skipTime)
                {
                    resultNode.SetAttribute("time", GetTimeString(rowResult.partTime));
                }

                XmlElement rowInputNode = doc.CreateElement("input");
                resultNode.AppendChild(rowInputNode);
                foreach (string inputKey in dataHolder.inputKeys)
                {
                    string input = GetInputData(inputKey, rowResult.inputDic);
                    rowInputNode.SetAttribute(inputKey, input);
                }
                if (rowResult.fixException != null)
                {
                    resultNode.SetAttribute("status", ResultType.ERROR);
                    resultNode.AppendChild(errorParser.AddXmlError(doc, rowResult.fixException));
                    result.Error();

                    XmlElement rowOutputNode = doc.CreateElement("output");
                    resultNode.AppendChild(rowOutputNode);

                    foreach (string outputKey in dataHolder.outputKeys)
                    {
                        XmlElement matchOutputNode = doc.CreateElement(outputKey);
                        rowOutputNode.AppendChild(matchOutputNode);
                        string outExpected = "";
                        if (rowResult.outputDic != null)
                        {
                            rowResult.outputDic.TryGetValue(outputKey, out outExpected);
                        }
                        matchOutputNode.SetAttribute("expected", outExpected);
                        matchOutputNode.SetAttribute("actual", "");
                        matchOutputNode.SetAttribute("status", ResultType.UNPROCESSED);
                    }
                }
                else
                {
                    XmlElement rowOutputNode = doc.CreateElement("output");
                    resultNode.AppendChild(rowOutputNode);

                    partPassed = BuildMatchingData(rowOutputNode, rowResult.outputDic, rowResult.resultDic, dataHolder.outputKeys, dataHolder.toleranceDic);
                    if (partPassed != ResultType.PASS)
                    {
                        resultNode.SetAttribute("status", ResultType.FAIL);
                        result.Fail();
                    }
                }
                resultNodes.Add(resultNode);
            }
            return resultNodes;
        }
开发者ID:MarMar,项目名称:SeeFlaw,代码行数:60,代码来源:ResultParser.cs

示例2: BuildMultiRowNode

        public XmlElement BuildMultiRowNode(ResultHolder dataHolder, Result result)
        {
            XmlElement resultNode = doc.CreateElement("result");

            ResultHolder.RowResult rowResult = dataHolder.singleRows[0];
            if (rowResult != null)
            {
                if (!dataHolder.skipTime)
                {
                    resultNode.SetAttribute("time", GetTimeString(rowResult.partTime));
                }

                XmlElement rowInputNode = doc.CreateElement("input");
                resultNode.AppendChild(rowInputNode);
                foreach (string inputKey in dataHolder.inputKeys)
                {
                    string input = GetInputData(inputKey, rowResult.inputDic);
                    rowInputNode.SetAttribute(inputKey, input);
                }
                if (rowResult.fixException != null)
                {
                    resultNode.SetAttribute("status", ResultType.UNPROCESSED);
                    resultNode.AppendChild(errorParser.AddXmlError(doc, rowResult.fixException));
                    result.Error();

                    foreach (Dictionary<string, string> outputDic in dataHolder.multiRows.multiOutput)
                    {
                        XmlElement resultOutputNode = doc.CreateElement("output");
                        resultOutputNode.SetAttribute("status", ResultType.UNPROCESSED);
                        resultNode.AppendChild(resultOutputNode);

                        foreach (string outputKey in dataHolder.multiRowKeys)
                        {
                            XmlElement matchOutputNode = doc.CreateElement(outputKey);
                            resultOutputNode.AppendChild(matchOutputNode);
                            string outExpected = "";
                            outputDic.TryGetValue(outputKey, out outExpected);
                            matchOutputNode.SetAttribute("expected", outExpected);
                            matchOutputNode.SetAttribute("actual", "");
                            matchOutputNode.SetAttribute("status", ResultType.UNPROCESSED);
                        }
                    }
                }
            }

            if (dataHolder.multiRows.multiResult != null)
            {
                List<Dictionary<string, object>> matchedResults = MatchOutputToResult(dataHolder);
                int matchIndex = 0;
                foreach (Dictionary<string, string> outputDic in dataHolder.multiRows.multiOutput)
                {
                    Dictionary<string, object> resultDic = matchedResults[matchIndex];
                    XmlElement resultOutputNode = doc.CreateElement("output");

                    string partPassed = BuildMatchingData(resultOutputNode, outputDic, resultDic, dataHolder.multiRowKeys, dataHolder.toleranceDic);
                    if (partPassed != ResultType.PASS)
                    {
                        result.Fail();
                    }
                    resultOutputNode.SetAttribute("status", partPassed);
                    resultNode.AppendChild(resultOutputNode);
                    matchIndex++;
                }
                if (matchIndex < matchedResults.Count)
                {
                    if (!dataHolder.allowSurplus)
                    {
                        result.Fail();
                    }
                    while (matchIndex < matchedResults.Count)
                    {
                        Dictionary<string, object> surplusDic = matchedResults[matchIndex];
                        XmlElement surplusNode = doc.CreateElement("output");
                        surplusNode.SetAttribute("status", ResultType.SURPLUS);

                        foreach (string outputKey in dataHolder.multiRowKeys)
                        {
                            object value = null;
                            if (surplusDic.ContainsKey(outputKey))
                            {
                                surplusDic.TryGetValue(outputKey, out value);
                            }
                            XmlElement outputNode = doc.CreateElement(outputKey);
                            outputNode.SetAttribute("expected", "");
                            outputNode.SetAttribute("actual", GetObjStr(value));
                            outputNode.SetAttribute("status", ResultType.SURPLUS);
                            surplusNode.AppendChild(outputNode);
                        }
                        resultNode.AppendChild(surplusNode);
                        matchIndex++;
                    }
                }
            }
            resultNode.SetAttribute("status", result.type);
            return resultNode;
        }
开发者ID:MarMar,项目名称:SeeFlaw,代码行数:96,代码来源:ResultParser.cs


注:本文中的System.Result.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。