Exemplo n.º 1
0
		/// <summary>
		/// Clones the test testResult
		/// </summary>
		public TestMethod Clone()
		{
			var method = new TestMethod()
			{
				Name = this.Name,
				Class = this.Class,
				Traits = this.Traits,
				ExecutionResult = this.ExecutionResult != null ? this.ExecutionResult.Clone() : null
			};

			return method;
		}
Exemplo n.º 2
0
        /// <summary>
        /// Discovers the tests in class.
        /// </summary>
        /// <param name="type">Type of the class.</param>
        /// <returns>Tests in the class</returns>
        private TestMethod[] DiscoverTestsInClass(TypeDefinition type, TestClass @class)
        {
            var tests = new List<TestMethod>();
            foreach (var method in type.Methods)
            {
                bool isTestMethod = false;
                var trait = new List<string>();

                try
                {
                    foreach (var attribute in method.CustomAttributes)
                    {
                        if (attribute.AttributeType.FullName == typeof(TestMethodAttribute).FullName)
                        {
                            isTestMethod = true;
                        }

                        AddTraits(trait, attribute, typeof(TestCategoryAttribute));
                    }
                }
                catch { }

                if (isTestMethod)
                {
                    TestMethod testMethod = new TestMethod();
                    testMethod.Name = method.Name;
                    testMethod.Traits = trait.Count > 0 ? trait.ToArray() : new[] { "No Traits" };
                    tests.Add(testMethod);
                }
            }

            return tests.ToArray();
        }