예제 #1
0
        public void MSTestDiscovererHasMSTestAdapterAsExecutorUri()
        {
            DefaultExecutorUriAttribute attribute = typeof(MSTestDiscoverer).GetTypeInfo().GetCustomAttributes(typeof(DefaultExecutorUriAttribute)).Cast <DefaultExecutorUriAttribute>().First();

            Assert.IsNotNull(attribute);
            Assert.AreEqual("executor://MSTestAdapter/v2", attribute.ExecutorUri);
        }
        /// <summary>
        /// Returns the value of default executor Uri on this type. 'Null' if not present.
        /// </summary>
        /// <param name="testDiscovererType"> The test discoverer Type. </param>
        /// <returns> The default executor URI. </returns>
        private static string GetDefaultExecutorUri(Type testDiscovererType)
        {
            string result = string.Empty;

            object[] attributes = testDiscovererType.GetTypeInfo().GetCustomAttributes(typeof(DefaultExecutorUriAttribute), false).ToArray();
            if (attributes != null && attributes.Length > 0)
            {
                DefaultExecutorUriAttribute executorUriAttribute = (DefaultExecutorUriAttribute)attributes[0];

                if (!string.IsNullOrEmpty(executorUriAttribute.ExecutorUri))
                {
                    result = executorUriAttribute.ExecutorUri;
                }
            }

            return(result);
        }