Beispiel #1
0
        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);
        }
Beispiel #2
0
        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.");
        }
        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);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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.");
        }
Beispiel #6
0
        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);
            });
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        public void Parse_WhenStringIsWellFormed_ReturnsParsedSignature(string signature,
                                                                        string expectedName, string expectedMinVersion, string expectedMaxVersion)
        {
            var sig = AssemblySignature.Parse(signature);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(expectedName, sig.Name);
                Assert.AreEqual(expectedMinVersion, sig.MinVersion != null ? sig.MinVersion.ToString() : null);
                Assert.AreEqual(expectedMaxVersion, sig.MaxVersion != null ? sig.MaxVersion.ToString() : null);
            });
        }
        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");
            }
        }
Beispiel #10
0
        public void ToString_ReturnsFormattedSignture(string signature)
        {
            var sig = AssemblySignature.Parse(signature);

            Assert.AreEqual(signature, sig.ToString());
        }
Beispiel #11
0
        public void Parse_WhenStringIsMalformed_Throws()
        {
            var ex = Assert.Throws <ArgumentException>(() => AssemblySignature.Parse("Abc-def"));

            Assert.Contains(ex.Message, "The specified assembly signature is not valid.");
        }
Beispiel #12
0
 public void Parse_WhenStringIsNull_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => AssemblySignature.Parse(null));
 }
Beispiel #13
0
        public void IsMatch_WhenAssemblyNameIsValid_ReturnsExpectedResult(string signature, string name, bool expectedResult)
        {
            var sig = AssemblySignature.Parse(signature);

            Assert.AreEqual(expectedResult, sig.IsMatch(new AssemblyName(name)));
        }
Beispiel #14
0
        public void IsMatch_WhenAssemblyNameIsNull_Throws()
        {
            var sig = new AssemblySignature("name");

            Assert.Throws <ArgumentNullException>(() => sig.IsMatch(null));
        }
Beispiel #15
0
        // TODO: Refactor me.
        private object ConvertConfigurationArgumentToType(Type type, string value)
        {
            if (type == typeof(string))
            {
                return(value);
            }

            if (type.IsEnum)
            {
                return(Enum.Parse(type, value, true));
            }

            if (type == typeof(Version))
            {
                return(new Version(value));
            }

            if (type == typeof(Guid))
            {
                return(new Guid(value));
            }

            if (type == typeof(Condition))
            {
                return(Condition.Parse(value));
            }

            if (type == typeof(Image))
            {
                return(Image.FromFile(ResolveResourcePath(value)));
            }

            if (type == typeof(Icon))
            {
                return(new Icon(ResolveResourcePath(value)));
            }

            if (type == typeof(FileInfo))
            {
                return(new FileInfo(ResolveResourcePath(value)));
            }

            if (type == typeof(DirectoryInfo))
            {
                return(new DirectoryInfo(ResolveResourcePath(value)));
            }

            if (type == typeof(AssemblyName))
            {
                return(new AssemblyName(value));
            }

            if (type == typeof(AssemblySignature))
            {
                return(AssemblySignature.Parse(value));
            }

            if (type == typeof(Assembly))
            {
                return(Assembly.Load(value));
            }

            if (type == typeof(Type))
            {
                return(Type.GetType(value));
            }

            if (value.StartsWith("${") && value.EndsWith("}"))
            {
                string componentId = value.Substring(2, value.Length - 3);

                object componentOrHandle;
                if (ComponentHandle.IsComponentHandleType(type))
                {
                    componentOrHandle = serviceLocator.ResolveHandleByComponentId(componentId);
                }
                else
                {
                    componentOrHandle = serviceLocator.ResolveByComponentId(componentId);
                }

                if (!type.IsInstanceOfType(componentOrHandle))
                {
                    throw new RuntimeException(string.Format("Could not inject component with id '{0}' into a dependency of type '{1}' because it is of the wrong type even though the component was explicitly specified using the '${{component.id}}' property value syntax.",
                                                             componentId, type));
                }

                return(componentOrHandle);
            }

            return(Convert.ChangeType(value, type, CultureInfo.InvariantCulture));
        }