/// <inheritdoc /> protected override void Initialize() { var testCaseSteps = new GallioHashSet <string>(); Events.AnnotationDiscovered += delegate(object sender, AnnotationDiscoveredEventArgs e) { LogAnnotation(e.Annotation); }; Events.TestStepStarted += delegate(object sender, TestStepStartedEventArgs e) { if (e.TestStepRun.Step.IsTestCase) { testCaseSteps.Add(e.TestStepRun.Step.Id); LogTestCaseStarted(e); } else { string parentId = e.TestStepRun.Step.ParentId; if (parentId != null && testCaseSteps.Contains(parentId)) { testCaseSteps.Add(e.TestStepRun.Step.Id); } } }; Events.TestStepFinished += delegate(object sender, TestStepFinishedEventArgs e) { if (e.TestStepRun.Step.IsTestCase) { testCaseSteps.Remove(e.TestStepRun.Step.Id); LogTestCaseFinished(e); } else { if (!testCaseSteps.Contains(e.TestStepRun.Step.Id)) { if (e.TestStepRun.Result.Outcome.Status != TestStatus.Passed && (e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Warnings) != null || e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Failures) != null)) { LogNonTestCaseProblem(e); } } else { testCaseSteps.Remove(e.TestStepRun.Step.Id); } } }; }
/// <summary> /// Obtains a unique local id for a child of this test. /// </summary> /// <param name="localIdHint">A suggested id which will be used if no conflicts occur.</param> /// <returns>The unique local id to use.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="localIdHint"/> is null.</exception> public string GetUniqueLocalIdForChild(string localIdHint) { if (localIdHint == null) { throw new ArgumentNullException("localIdHint"); } string candidateLocalId = localIdHint; if (assignedChildLocalIds == null) { assignedChildLocalIds = new GallioHashSet <string>(); } else { int index = 2; while (assignedChildLocalIds.Contains(candidateLocalId)) { candidateLocalId = localIdHint + index; index += 1; } } assignedChildLocalIds.Add(candidateLocalId); return(candidateLocalId); }
/// <inheritdoc /> public IEnumerable <IDataItem> Merge(IList <IDataProvider> providers, ICollection <DataBinding> bindings, bool includeDynamicItems) { var previousValues = new GallioHashSet <object[]>(new ArrayEqualityComparer <object>()); foreach (IDataProvider provider in providers) { foreach (IDataItem item in provider.GetItems(bindings, includeDynamicItems)) { try { object[] values = GenericCollectionUtils.ConvertAllToArray <DataBinding, object>(bindings, delegate(DataBinding binding) { return(item.GetValue(binding)); }); if (previousValues.Contains(values)) { continue; } previousValues.Add(values); } catch { // Always consider items whose bindings cannot be evaluated correctly as distinct. } yield return(item); } } }
private void Add(int hash) { if (one.Contains(hash)) { one.Remove(hash); two.Add(hash); } else if (two.Contains(hash)) { two.Remove(hash); more.Add(hash, 3); } else { int n; if (more.TryGetValue(hash, out n)) { more[hash] = 1 + n; } else { one.Add(hash); } } }
private void RegisterAttachment(string attachmentName) { if (attachmentNames == null) { attachmentNames = new GallioHashSet <string>(); } attachmentNames.Add(attachmentName); }
/// <summary> /// Defines a preprocessor constant. /// </summary> /// <param name="constant">The constant.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="constant"/> /// is null.</exception> public void Define(string constant) { if (constant == null) { throw new ArgumentNullException("constant"); } constants.Add(constant); }
/// <inheritdoc /> public void DefinePreprocessorConstant(string constant) { if (constant == null) { throw new ArgumentNullException("constant"); } initialPreprocessorConstants.Add(constant); }
private void HandleTaskStarted(object sender, TaskEventArgs e) { EventHandler <TaskEventArgs> cachedChain; lock (this) { activeTasks.Add(e.Task); cachedChain = started; } EventHandlerPolicy.SafeInvoke(cachedChain, this, e); }
/// <summary> /// Prepares to populate the children of the assembly test on demand by /// adding a deferred populator with <see cref="IPatternScope.AddDeferredComponentPopulator" />. /// </summary> /// <param name="assemblyScope">The assembly scope.</param> /// <param name="assembly">The assembly.</param> protected virtual void PrepareToPopulateChildrenOnDemand(IPatternScope assemblyScope, IAssemblyInfo assembly) { var populatedTypes = new GallioHashSet <ITypeInfo>(); assemblyScope.AddDeferredComponentPopulator(childCodeElementHint => { ITypeInfo type = childCodeElementHint as ITypeInfo; if (type != null && !type.IsNested && !populatedTypes.Contains(type) && assembly.Equals(type.Assembly)) { populatedTypes.Add(type); assemblyScope.Consume(type, false, DefaultTypePattern); } }); }
public void Add(Type type) { if (type == null) { throw new ArgumentNullException("type"); } if (type.IsGenericType) { type = type.GetGenericTypeDefinition(); } types.Add(type); }