/// <summary> /// Parses the assembly signature from a string. /// </summary> /// <remarks> /// <para> /// The string takes the form of following forms: /// <list type="bullet"> /// <item>"AssemblyName"</item> /// <item>"AssemblyName, Version=1.2.0.0"</item> /// <item>"AssemblyName, Version=1.2.0.0-1.3.65535.65535"</item> /// </list> /// </para> /// </remarks> /// <param name="str">The string to parse.</param> /// <returns>The parsed signature.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="str"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="str"/> is malformed.</exception> public static AssemblySignature Parse(string str) { if (str == null) { throw new ArgumentNullException("str"); } Match match = ParseRegex.Match(str); if (!match.Success) { throw new ArgumentException("The specified assembly signature is not valid.", "str"); } string name = match.Groups["name"].Value; string minVersion = match.Groups["minVersion"].Value; string maxVersion = match.Groups["maxVersion"].Value; var signature = new AssemblySignature(name); if (minVersion.Length != 0) { if (maxVersion.Length != 0) { signature.SetVersionRange(new Version(minVersion), new Version(maxVersion)); } else { signature.SetVersion(new Version(minVersion)); } } return(signature); }
public void SetVersionRange_WhenBothArgumentsNotNull_SetsBothMinAndMaxVersion() { var sig = new AssemblySignature("name"); sig.SetVersionRange(new Version(1, 0, 0, 0), new Version(1, 2, 65535, 65535)); Assert.AreEqual(new Version(1, 0, 0, 0), sig.MinVersion); Assert.AreEqual(new Version(1, 2, 65535, 65535), sig.MaxVersion); }
public void SetVersionRange_WhenBothArgumentsNull_SetsBothMinAndMaxVersion() { var sig = new AssemblySignature("name"); sig.SetVersion(new Version(1, 2, 3, 4)); sig.SetVersionRange(null, null); Assert.IsNull(sig.MinVersion); Assert.IsNull(sig.MaxVersion); }
public void SetVersionRange_WhenOneArgumentNullButNotTheOther_Throws() { var sig = new AssemblySignature("name"); var ex = Assert.Throws<ArgumentException>(() => sig.SetVersionRange(null, new Version(1, 2, 3, 4))); Assert.Contains(ex.Message, "Min and max version must either both be non-null or both be null."); ex = Assert.Throws<ArgumentException>(() => sig.SetVersionRange(new Version(1, 2, 3, 4), null)); Assert.Contains(ex.Message, "Min and max version must either both be non-null or both be null."); }
public void Constructor_WhenNameIsValid_ReturnsInitializedInstance() { var sig = new AssemblySignature("name"); Assert.Multiple(() => { Assert.AreEqual("name", sig.Name); Assert.IsNull(sig.MinVersion); Assert.IsNull(sig.MaxVersion); }); }
public void SetVersion_SetsBothMinAndMaxVersion() { var sig = new AssemblySignature("name"); sig.SetVersion(new Version(1, 2, 3, 4)); Assert.AreEqual(new Version(1, 2, 3, 4), sig.MinVersion); Assert.AreEqual(new Version(1, 2, 3, 4), sig.MaxVersion); sig.SetVersion(null); Assert.IsNull(sig.MinVersion); Assert.IsNull(sig.MaxVersion); }
/// <summary> /// Parses the assembly signature from a string. /// </summary> /// <remarks> /// <para> /// The string takes the form of following forms: /// <list type="bullet"> /// <item>"AssemblyName"</item> /// <item>"AssemblyName, Version=1.2.0.0"</item> /// <item>"AssemblyName, Version=1.2.0.0-1.3.65535.65535"</item> /// </list> /// </para> /// </remarks> /// <param name="str">The string to parse.</param> /// <returns>The parsed signature.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="str"/> is null.</exception> /// <exception cref="ArgumentException">Thrown if <paramref name="str"/> is malformed.</exception> public static AssemblySignature Parse(string str) { if (str == null) throw new ArgumentNullException("str"); Match match = ParseRegex.Match(str); if (! match.Success) throw new ArgumentException("The specified assembly signature is not valid.", "str"); string name = match.Groups["name"].Value; string minVersion = match.Groups["minVersion"].Value; string maxVersion = match.Groups["maxVersion"].Value; var signature = new AssemblySignature(name); if (minVersion.Length != 0) { if (maxVersion.Length != 0) { signature.SetVersionRange(new Version(minVersion), new Version(maxVersion)); } else { signature.SetVersion(new Version(minVersion)); } } return signature; }
private void InstallRegistryKeysForFramework(string frameworkName, AssemblySignature frameworkAssembly, int priority, IProgressMonitor progressMonitor, RegistryKey hiveKey, string rootKeyPath) { string subKeyName = string.Concat(rootKeyPath, @"\", RunnerRegKeyPrefix, " - ", frameworkName, " (", frameworkAssembly, ")"); string message = string.Format("Adding TestDriven.Net runner registry key for framework '{0}'.", frameworkName); logger.Log(LogSeverity.Info, message); progressMonitor.SetStatus(message); using (RegistryKey subKey = hiveKey.CreateSubKey(subKeyName, RegistryKeyPermissionCheck.ReadWriteSubTree)) { subKey.SetValue(null, priority.ToString()); subKey.SetValue("AssemblyPath", AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)); subKey.SetValue("TargetFrameworkAssemblyName", frameworkAssembly.ToString()); // n.b. TDNet supports version ranges in the same format we use subKey.SetValue("TypeName", "Gallio.TDNetRunner.GallioTestRunner"); subKey.SetValue("TypeName_Resident", "Gallio.TDNetRunner.GallioResidentTestRunner"); } }
private void InstallRegistryKeysForFramework(string frameworkName, AssemblySignature frameworkAssembly, int priority, IProgressMonitor progressMonitor) { InstallRegistryKeysForFramework(frameworkName, frameworkAssembly, priority, progressMonitor, Registry.LocalMachine, LocalMachineRegKey); if (ProcessSupport.Is64BitProcess) InstallRegistryKeysForFramework(frameworkName, frameworkAssembly, priority, progressMonitor, Registry.LocalMachine, LocalMachineRegKeyWow3264Node); }
public void SetVersionRange_WhenMinGreaterThanMax_Throws() { var sig = new AssemblySignature("name"); var ex = Assert.Throws<ArgumentException>(() => sig.SetVersionRange(new Version(2, 0, 0, 0), new Version(1, 2, 3, 4))); Assert.Contains(ex.Message, "Min version must be less than or equal to max version."); }
public void IsMatch_WhenAssemblyNameIsNull_Throws() { var sig = new AssemblySignature("name"); Assert.Throws<ArgumentNullException>(() => sig.IsMatch(null)); }