public void TestTestOrderAttribute() { TestOrderAttribute testOrder = new TestOrderAttribute(0); Assert.AreEqual(0, testOrder.Index); testOrder.Index = 2; Assert.AreEqual(2, testOrder.Index); }
/// <summary> /// Get testcase list /// </summary> /// <param name="testClasses"></param> /// <param name="sender"></param> /// <returns></returns> public dynamic GetTestCaseList(List <string> testClasses, Assembly sender) { IList <TestCaseModel> testCaseList = new List <TestCaseModel>(); foreach (string testClass in testClasses) { //string moduleType = TestModuleService.GetModuleType(testClass, sender); //ObjectId objectId = mongoRepository.GetTestModuleRepository.GetId(moduleType); ObjectId objectId = mongoRepository.GetTestClassRepository.GetId(testClass); //Get test methods Type type = sender.GetType(testClass); IEnumerable <MethodInfo> methods = type.GetMethods() .Where(t => t.IsDefined(typeof(TestInfoAttribute), false) && t.IsDefined(typeof(ExecuteAttribute), false)); foreach (MethodInfo method in methods) { IList <Type> attributes = GetAvailableAttributes(method); TestInfoAttribute testAttrInfo = null; TestOrderAttribute orderAttrInfo = null; DependentAttribute dependentAttribute = null; bool isExecute = false; if (attributes.Count != 0) { foreach (Type attribute in attributes) { if (attribute.Name.Equals("ExecuteAttribute") || attribute.Name.Equals("Execute")) { ExecuteAttribute executeTestCaseAttribute = method.GetExecuteAttribute(); isExecute = executeTestCaseAttribute.ExecuteType == ExecuteType.Execute ? true : false; } else if (attribute.Name.Equals("TestInfoAttribute") || attribute.Name.Equals("TestInfo")) { testAttrInfo = method.GetTestInfoAttribute(); } else if (attribute.Name.Equals("TestOrderAttribute") || attribute.Name.Equals("TestOrder")) { orderAttrInfo = method.GetTestOrderAttribute(); } else if (attribute.Name.Equals("DependentAttribute") || attribute.Name.Equals("Dependent")) { dependentAttribute = method.GetDependentAttribute(); } } testCaseList.Add(new TestCaseModel() { TestClass_id = objectId, TestCaseName = method.Name, TestCaseDescription = method.Name, TestCaseType = testAttrInfo.TestCaseType.ToString(), //CreatedDTM = DateTime.UtcNow, TestCasePriority = testAttrInfo.Priority.ToString(), TestCategory = testAttrInfo.TestCategory.ToString(), Version = testAttrInfo.Version.ToString(), DependentTestCaseName = dependentAttribute?.TestMethodName, Order = orderAttrInfo.Order, IsActive = isExecute }); } } } return(testCaseList); }