/// <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); } } }
/// <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); }
public ImmutableTypeCollection() { types = new GallioHashSet <Type> { typeof(Boolean), typeof(Int16), typeof(Int32), typeof(Int64), typeof(IntPtr), typeof(UInt16), typeof(UInt32), typeof(UInt64), typeof(UIntPtr), typeof(Single), typeof(Double), typeof(Decimal), typeof(Byte), typeof(Char), typeof(String), typeof(DateTime), typeof(TimeSpan), typeof(ReadOnlyCollectionBase), typeof(ReadOnlyCollection <>), typeof(ReadOnlyDictionary <,>), }; }
/// <summary> /// Creates a file system plugin loader. /// </summary> public PluginLoader() { pluginPaths = new List <string>(); pluginXmls = new List <Pair <string, DirectoryInfo> >(); initialPreprocessorConstants = new GallioHashSet <string>(); InstallationId = Guid.Empty; }
/// <summary> /// Loads plugins by recursively searching the plugin paths for *.plugin files. /// </summary> /// <param name="pluginCallback">A function that receives plugin metadata as it /// becomes available, not null.</param> /// <param name="progressMonitor"></param> protected virtual void LoadPlugins(PluginCallback pluginCallback, IProgressMonitor progressMonitor) { if (pluginPaths.Count == 0) { return; } var uniquePluginFilePaths = new GallioHashSet <string>(); using (progressMonitor.BeginTask("Loading plugins", pluginPaths.Count)) { foreach (var pluginPath in pluginPaths) { using (var subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1)) { var pluginDirectory = new DirectoryInfo(pluginPath); if (pluginDirectory.Exists) { LoadPluginsFromDirectory(pluginDirectory, uniquePluginFilePaths, pluginCallback, subProgressMonitor); } else { var pluginFile = new FileInfo(pluginPath); if (pluginFile.Exists) { LoadPluginsFromFile(pluginFile, uniquePluginFilePaths, pluginCallback, subProgressMonitor); } } } } } }
/// <inheritdoc /> public override IList <IEventInfo> GetEvents(BindingFlags bindingFlags) { List <IEventInfo> result = new List <IEventInfo>(); AddAll(result, EnumerateEvents(bindingFlags, this)); BindingFlags inheritanceBindingFlags = GetInheritanceBindingFlags(bindingFlags); if (inheritanceBindingFlags != BindingFlags.Default) { GallioHashSet <StaticEventWrapper> overrides = new GallioHashSet <StaticEventWrapper>(); foreach (StaticEventWrapper @event in result) { AddAll(overrides, @event.GetOverridenOrHiddenEvents(false)); } foreach (StaticDeclaredTypeWrapper baseType in GetAllBaseTypes()) { foreach (StaticEventWrapper inheritedEvent in baseType.EnumerateEvents(inheritanceBindingFlags, this)) { if (!overrides.Contains(inheritedEvent)) { result.Add(inheritedEvent); AddAll(overrides, inheritedEvent.GetOverridenOrHiddenEvents(false)); } } } } return(result); }
private IList <IMethodInfo> GetMethods(BindingFlags bindingFlags, bool excludeOverridesOnly) { List <IMethodInfo> result = new List <IMethodInfo>(); AddAll(result, EnumerateDeclaredMethods(bindingFlags, this)); BindingFlags inheritanceBindingFlags = GetInheritanceBindingFlags(bindingFlags); if (inheritanceBindingFlags != BindingFlags.Default) { GallioHashSet <StaticMethodWrapper> overrides = new GallioHashSet <StaticMethodWrapper>(); foreach (StaticMethodWrapper method in result) { AddAll(overrides, method.GetOverridenOrHiddenMethods(excludeOverridesOnly)); } foreach (StaticDeclaredTypeWrapper baseType in GetAllBaseTypes()) { foreach (StaticMethodWrapper inheritedMethod in baseType.EnumerateDeclaredMethods(inheritanceBindingFlags, this)) { if (!overrides.Contains(inheritedMethod) && !IsSpecialNonInheritedMethod(inheritedMethod)) { result.Add(inheritedMethod); AddAll(overrides, inheritedMethod.GetOverridenOrHiddenMethods(excludeOverridesOnly)); } } } } return(result); }
private void RegisterAttachment(string attachmentName) { if (attachmentNames == null) { attachmentNames = new GallioHashSet <string>(); } attachmentNames.Add(attachmentName); }
/// <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> /// Closes the markup document writer. /// </summary> public void Close() { lock (this) { if (!isClosed) { CloseImpl(); isClosed = true; attachmentNames = null; streamDepths = null; } } }
/// <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 HtmlTestStepRunFormatter() { var runtime = RuntimeAccessor.Instance; var resourcesPath = runtime.ResourceLocator.ResolveResourcePath(new Uri("plugin://Gallio.Reports/Resources/")); resourcesUrl = new Uri(resourcesPath); cssUrl = new Uri(resourcesUrl, "css"); imgUrl = new Uri(resourcesUrl, "img"); jsDir = Path.Combine(resourcesPath, "js"); cache = new TemporaryDiskCache("Gallio.UI"); cacheGroup = cache.Groups[Guid.NewGuid().ToString()]; reportFilePool = new ReportFilePool(cacheGroup, 5); attachmentPaths = new GallioHashSet <string>(); }
/// <summary> /// Creates an Xml preprocessor. /// </summary> public XmlPreprocessor() { constants = new GallioHashSet <string>(); }
/// <summary> /// Creates an empty task container. /// </summary> public TaskContainer() { activeTasks = new GallioHashSet <Task>(); }
private TestFrameworkSelection GetFallbackSelection( Dictionary <object, TestFrameworkSelection> selections, IList <AssemblyName> assemblyReferences, IEnumerable <ComponentHandle <ITestFramework, TestFrameworkTraits> > filteredTestFrameworkHandlesWithoutFallback, TestFrameworkOptions testFrameworkOptions, TestFrameworkFallbackMode testFrameworkFallbackMode) { // Strict fallback mode. if (testFrameworkFallbackMode == TestFrameworkFallbackMode.Strict) { return(null); } // Approximate fallback mode. if (assemblyReferences != null) { GallioHashSet <string> matchingReferences = null; GallioHashSet <string> matchingSignatures = null; foreach (var testFrameworkHandle in filteredTestFrameworkHandlesWithoutFallback) { IList <AssemblySignature> assemblySignatures = testFrameworkHandle.GetTraits().FrameworkAssemblies; foreach (AssemblyName assemblyName in assemblyReferences) { foreach (AssemblySignature assemblySignature in assemblySignatures) { if (assemblySignature.Name == assemblyName.Name) { if (matchingReferences == null) { matchingReferences = new GallioHashSet <string>(); matchingSignatures = new GallioHashSet <string>(); } matchingReferences.Add(assemblyName.FullName); matchingSignatures.Add(assemblySignature.ToString()); } } } } if (matchingReferences != null) { StringBuilder fallbackExplanationBuilder = new StringBuilder(); fallbackExplanationBuilder.Append("Detected a probable test framework assembly version mismatch.\n"); fallbackExplanationBuilder.Append("Referenced test frameworks: "); AppendQuotedItems(fallbackExplanationBuilder, matchingReferences); fallbackExplanationBuilder.Append(".\n"); fallbackExplanationBuilder.Append("Supported test frameworks: "); AppendQuotedItems(fallbackExplanationBuilder, matchingSignatures); fallbackExplanationBuilder.Append("."); string fallbackExplanation = fallbackExplanationBuilder.ToString(); return(GetOrCreateSelectionIfAbsent(selections, fallbackExplanation, () => { TestFrameworkOptions fallbackTestFrameworkOptions = testFrameworkOptions.Copy(); fallbackTestFrameworkOptions.AddProperty(FallbackTestFramework.FallbackExplanationKey, fallbackExplanation); return new TestFrameworkSelection(fallbackTestFrameworkHandle, fallbackTestFrameworkOptions, true); })); } } if (testFrameworkFallbackMode == TestFrameworkFallbackMode.Approximate) { return(null); } // Default fallback mode. return(GetOrCreateSelectionIfAbsent(selections, DefaultFallbackSelectionKey, () => new TestFrameworkSelection(fallbackTestFrameworkHandle, testFrameworkOptions, true))); }