/// <summary> /// Gets the navigation data for a method declared in a type. /// </summary> /// <param name="declaringTypeName"> The declaring type name. </param> /// <param name="methodName"> The method name. </param> /// <returns> The <see cref="INavigationData" /> for that method. </returns> public INavigationData GetNavigationDataForMethod(string declaringTypeName, string methodName) { ValidateArg.NotNullOrEmpty(declaringTypeName, "declaringTypeName"); ValidateArg.NotNullOrEmpty(methodName, "methodName"); methodName = methodName.TrimEnd(TestNameStripChars); return(this.symbolReader.GetNavigationData(declaringTypeName, methodName)); }
public static TestProperty Register(string id, string label, Type valueType, TestPropertyAttributes attributes, Type owner) { ValidateArg.NotNullOrEmpty(id, "id"); ValidateArg.NotNull(label, "label"); ValidateArg.NotNull(valueType, "valueType"); ValidateArg.NotNull(owner, "owner"); return Register(id, label, string.Empty, string.Empty, valueType, null, attributes, owner); }
public static TestProperty Register(string id, string label, Type valueType, TestPropertyAttributes attributes, Type owner) { ValidateArg.NotNullOrEmpty(id, nameof(id)); ValidateArg.NotNull(label, nameof(label)); ValidateArg.NotNull(valueType, nameof(valueType)); ValidateArg.NotNull(owner, nameof(owner)); return Register(id, label, string.Empty, string.Empty, valueType, null, attributes, owner); }
/// <summary> /// Initializes a new instance of the <see cref="TestCase"/> class. /// </summary> /// <param name="fullyQualifiedName"> /// Fully qualified name of the test case. /// </param> /// <param name="executorUri"> /// The Uri of the executor to use for running this test. /// </param> /// <param name="source"> /// Test container source from which the test is discovered. /// </param> public TestCase(string fullyQualifiedName, Uri executorUri, string source) { ValidateArg.NotNullOrEmpty(fullyQualifiedName, "fullyQualifiedName"); ValidateArg.NotNull(executorUri, "executorUri"); ValidateArg.NotNullOrEmpty(source, "source"); this.FullyQualifiedName = fullyQualifiedName; this.ExecutorUri = executorUri; this.Source = source; }
public static TestProperty Register(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes, Type owner) { ValidateArg.NotNullOrEmpty(id, "id"); ValidateArg.NotNull(label, "label"); ValidateArg.NotNull(category, "category"); ValidateArg.NotNull(description, "description"); ValidateArg.NotNull(valueType, "valueType"); ValidateArg.NotNull(owner, "owner"); TestProperty result; KeyValuePair<TestProperty, HashSet<Type>> propertyTypePair; lock (s_properties) { if (s_properties.TryGetValue(id, out propertyTypePair)) { // verify the data valueType is valid if (propertyTypePair.Key.ValueType == valueType.AssemblyQualifiedName || propertyTypePair.Key.ValueType == valueType.FullName || propertyTypePair.Key.valueType == valueType) { // add the owner to set of owners for this GraphProperty object propertyTypePair.Value.Add(owner); result = propertyTypePair.Key; } else { // not the data valueType we expect, throw an exception string message = string.Format( CultureInfo.CurrentCulture, Resources.Resources.Exception_RegisteredTestPropertyHasDifferentValueType, id, valueType.ToString(), propertyTypePair.Key.ValueType); throw new InvalidOperationException(message); } } else { // create a new TestProperty object result = new TestProperty(id, label, category, description, valueType, validateValueCallback, attributes); // setup the data pair used to track owners of this GraphProperty propertyTypePair = new KeyValuePair<TestProperty, HashSet<Type>>(result, new HashSet<Type>()); propertyTypePair.Value.Add(owner); // add to the dictionary s_properties[id] = propertyTypePair; } } return result; }
/// <summary> /// Initializes a new instance of the <see cref="TestCase"/> class. /// </summary> /// <param name="fullyQualifiedName"> /// Fully qualified name of the test case. /// </param> /// <param name="executorUri"> /// The Uri of the executor to use for running this test. /// </param> /// <param name="source"> /// Test container source from which the test is discovered. /// </param> public TestCase(string fullyQualifiedName, Uri executorUri, string source) { ValidateArg.NotNullOrEmpty(fullyQualifiedName, nameof(fullyQualifiedName)); ValidateArg.NotNull(executorUri, nameof(executorUri)); ValidateArg.NotNullOrEmpty(source, nameof(source)); this.FullyQualifiedName = fullyQualifiedName; this.ExecutorUri = executorUri; this.Source = source; this.LineNumber = -1; }
public static bool TryUnregister(string id, out KeyValuePair<TestProperty, HashSet<Type>> propertyTypePair) { ValidateArg.NotNullOrEmpty(id, "id"); lock (s_properties) { if (s_properties.TryGetValue(id, out propertyTypePair)) { return s_properties.Remove(id); } } return false; }
private TestProperty(string id, string label, string category, string description, Type valueType, ValidateValueCallback validateValueCallback, TestPropertyAttributes attributes) { ValidateArg.NotNullOrEmpty(id, "id"); ValidateArg.NotNull(label, "label"); ValidateArg.NotNull(category, "category"); ValidateArg.NotNull(description, "description"); ValidateArg.NotNull(valueType, "valueType"); // If the type of property is unexpected, then fail as otherwise we will not be to serialize it over the wcf channel and serialize it in db. if (valueType == typeof(KeyValuePair<string, string>[])) { this.ValueType = "System.Collections.Generic.KeyValuePair`2[[System.String],[System.String]][]"; } else if (valueType == typeof(string) || valueType == typeof(Uri) || valueType == typeof(string[]) || valueType.AssemblyQualifiedName.Contains("System.Private") || valueType.AssemblyQualifiedName.Contains("mscorlib")) { // This comparison is a check to ensure assembly information is not embedded in data. // Use type.FullName instead of type.AssemblyQualifiedName since the internal assemblies // are different in desktop and coreclr. Thus AQN in coreclr includes System.Private.CoreLib which // is not available on the desktop. // Note that this doesn't handle generic types. Such types will fail during serialization. this.ValueType = valueType.FullName; } else if (valueType.GetTypeInfo().IsValueType) { // In case of custom types, let the assembly qualified name be available to help // deserialization on the client. this.ValueType = valueType.AssemblyQualifiedName; } else { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Resources.UnexpectedTypeOfProperty, valueType, id)); } this.Id = id; this.Label = label; this.Category = category; this.Description = description; this.ValidateValueCallback = validateValueCallback; this.Attributes = attributes; this.valueType = valueType; }
internal static DataCollectorSettings FromXml(XmlReader reader) { DataCollectorSettings settings = new DataCollectorSettings(); settings.IsEnabled = true; bool empty = reader.IsEmptyElement; if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "uri": ValidateArg.NotNullOrEmpty(reader.Value, "uri"); try { settings.Uri = new Uri(reader.Value); } catch (UriFormatException) { throw new SettingsException(String.Format(CultureInfo.CurrentCulture, Resources.Resources.InvalidDataCollectorUriInSettings, reader.Value)); } break; case "assemblyQualifiedName": ValidateArg.NotNullOrEmpty(reader.Value, "assemblyQualifiedName"); settings.AssemblyQualifiedName = reader.Value; break; case "friendlyName": ValidateArg.NotNullOrEmpty(reader.Value, "FriendlyName"); settings.FriendlyName = reader.Value; break; case "enabled": settings.IsEnabled = bool.Parse(reader.Value); break; case "codebase": settings.CodeBase = reader.Value; // Optional. break; default: throw new SettingsException( String.Format( CultureInfo.CurrentCulture, Resources.Resources.InvalidSettingsXmlAttribute, Constants.DataCollectionRunSettingsName, reader.Name)); } } } if (string.IsNullOrWhiteSpace(settings.FriendlyName)) { throw new SettingsException( String.Format(CultureInfo.CurrentCulture, Resources.Resources.MissingDataCollectorAttributes, "FriendlyName")); } reader.Read(); if (!empty) { while (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Configuration": XmlDocument doc = new XmlDocument(); XmlElement element = doc.CreateElement("Configuration"); element.InnerXml = reader.ReadInnerXml(); settings.Configuration = element; break; default: throw new SettingsException( String.Format( CultureInfo.CurrentCulture, Resources.Resources.InvalidSettingsXmlElement, Constants.DataCollectionRunSettingsName, reader.Name)); } } reader.ReadEndElement(); } return(settings); }
internal DiaSession(string binaryPath, string searchPath, ISymbolReader symbolReader) { this.symbolReader = symbolReader; ValidateArg.NotNullOrEmpty(binaryPath, "binaryPath"); this.symbolReader.CacheSymbols(binaryPath, searchPath); }
/// <summary> /// Initializes with the name of the test case. /// </summary> /// <param name="name">The name of the test case.</param> protected TestRunSettings(string name) { ValidateArg.NotNullOrEmpty(name, "name"); this.name = name; }