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


C# IOperation.GetExecutedChildOperationsForOperationHierarchy方法代码示例

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


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

示例1: VerifyExecutedOperations

        private static void VerifyExecutedOperations(IOperation operation, Type[] expectedOperationTypes, bool allowOperationFailures)
        {
            Verify.NotNull(operation, nameof(operation));
            Verify.NotNull(expectedOperationTypes, nameof(expectedOperationTypes));

            var messageParts = new List<string>(expectedOperationTypes.Length + 2) { "Operations", "==========" };
            var executedOperations = operation.GetExecutedChildOperationsForOperationHierarchy().ToList();
            var items = Math.Max(expectedOperationTypes.Length, executedOperations.Count);
            var hasErrors = false;
            for (var i = 0; i < items; i++)
            {
                if (i >= executedOperations.Count)
                {
                    messageParts.Add("none [error: expected " + expectedOperationTypes[i].Name + "]");
                    hasErrors = true;
                    continue;
                }

                var executedOperationType = executedOperations[i].Operation.GetType();

                if (i >= expectedOperationTypes.Length)
                {
                    messageParts.Add(executedOperationType.Name + " [error: expected none]");
                    hasErrors = true;
                    continue;
                }

                if (executedOperationType != expectedOperationTypes[i])
                {
                    messageParts.Add(executedOperationType.Name + " [error: expected " + expectedOperationTypes[i].Name + "]");
                    hasErrors = true;
                    continue;
                }

                var hasFailedOperation = !allowOperationFailures && executedOperations[i].Error != null;
                hasErrors = hasErrors || hasFailedOperation;
                var matchMessage = hasFailedOperation ? " [match, failed]" : " [match]";
                messageParts.Add(expectedOperationTypes[i].Name + matchMessage);
            }

            if (hasErrors)
                throw new AssertionException(string.Join(Environment.NewLine, messageParts));
        }
开发者ID:rrl9000,项目名称:Overflow.net,代码行数:43,代码来源:OperationExtensions.cs


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