private IEnumerable <IClass> GetTestClassesDerivedFrom(IClass c) { return(TestClasses .Where(testClass => testClass.IsDerivedFrom(c)) .Select(testClass => testClass.Class) .ToArray()); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddInMemoryClasses(TestClasses.Get()); services.AddInMemorySkills(TestSkills.Get()); services.AddControllers(); services.AddSwaggerGen(); }
/// <summary> /// Updates the test class methods based on the newly parsed class /// information. /// </summary> void UpdateTestClass(IClass c) { if (TestClasses.Contains(c.DotNetName)) { if (IsTestClass(c)) { TestClass testClass = TestClasses[c.DotNetName]; testClass.UpdateClass(c); } else { // TestFixture attribute has been removed so // remove the class from the set of TestClasses. TestClasses.Remove(c.DotNetName); } } else { // TestFixture attribute may have been recently added to // this class so call AddNewTestClass. No need to // check if the class is actually a test class since // AddNewTestClass does this anyway. AddNewTestClass(c); } var derivedTestClasses = GetTestClassesDerivedFrom(c); if (derivedTestClasses.Any()) { UpdateClassesFromProjectContent(derivedTestClasses); } }
/// <summary> /// Adds a new class to the test project's classes only if /// the class is a test class. /// </summary> void AddNewTestClass(IClass c) { if (IsTestClass(c)) { TestClass testClass = CreateTestClass(c); TestClasses.Add(testClass); } }
/// <summary> /// Adds a new class to the test project's classes only if /// the class is a test class. /// </summary> void AddNewTestClass(IClass c) { if (TestClass.IsTestClass(c)) { TestClass testClass = new TestClass(c); TestClasses.Add(testClass); } }
public Runner(string pathDll) { NbTest = 0; NbSucceedTest = 0; NbFailedTest = 0; LoadDll(pathDll); TestClasses = this.Dll.DefinedTypes.Where(typeInfo => typeInfo.CustomAttributes.Any(customAttributeData => customAttributeData.AttributeType.Name == "TestClass")).ToList(); var methods = new List <MethodInfo>(); TestClasses.ForEach(typeInfo => typeInfo.GetMethods().ToList().ForEach(methodInfo => methods.Add(methodInfo))); TestMethods = methods.Where(methodInfo => methodInfo.CustomAttributes.Any(customAttributeData => customAttributeData.AttributeType.Name == "Test")).ToList(); }
/// <summary> /// Updates the classes and methods based on the new parse information. /// </summary> /// <param name="oldUnit">The old compiliation unit /// (ParseInformationEventArgs.ParseInformation.BestCompilationUnit as ICompilationUnit)</param> /// <param name="newUnit">The new compilation unit /// (ParseInformationEventArgs.CompilationUnit).</param> public void UpdateParseInfo(ICompilationUnit oldUnit, ICompilationUnit newUnit) { if (!IsParseInfoForThisProject(oldUnit, newUnit)) { return; } RemovedClasses removedClasses = new RemovedClasses(); if (oldUnit != null) { removedClasses.Add(oldUnit.Classes); } if (newUnit != null) { foreach (IClass c in newUnit.Classes) { UpdateTestClass(c); foreach (IClass innerClass in new InnerClassEnumerator(c)) { UpdateTestClass(innerClass); removedClasses.Remove(innerClass); } removedClasses.Remove(c); } } // Remove missing classes. foreach (IClass c in removedClasses.GetMissingClasses()) { IClass existingClass = GetExistingTestClassInProject(c); if (existingClass != null) { UpdateTestClass(existingClass); } else { TestClasses.Remove(c.DotNetName); } } }
void FindAssemblyCleanupMethod() { var methods = TestClasses .Select(c => c.AssemblyCleanupMethod) .Where(c => c != null) .ToList(); if (methods.Count > 1) { throw new UserException( $"[TestAssembly] {Assembly.FullName} contains more than one [AssemblyCleanup] method"); } if (methods.Count == 0) { return; } AssemblyCleanupMethod = methods[0]; }
void FindAssemblyCleanupMethod() { var methods = TestClasses .Select(c => c.AssemblyCleanupMethod) .Where(c => c != null) .ToList(); if (methods.Count > 1) { throw new UserException( StringExtensions.FormatInvariant( "[TestAssembly] {0} contains more than one [AssemblyCleanup] method", Assembly.FullName)); } if (methods.Count == 0) { return; } AssemblyCleanupMethod = methods[0]; }
private ClassTask GetTestClass(TestExecutionClassClientEvent message) { var fullClassName = string.Format("{0}.{1}", message.NamespaceName, message.ClassName); return(TestClasses.FirstOrDefault(c => c.GetFullClassName() == fullClassName)); }
/// <summary> /// Sets all the test results back to none. /// </summary> public void ResetTestResults() { TestClasses.ResetTestResults(); }
/// <summary> /// Updates the test method based on the test result. /// </summary> public void UpdateTestResult(TestResult testResult) { TestClasses.UpdateTestResult(testResult); }
private TestFile(string path, string name, TestClasses testClasses) { Path = path; Name = name; TestClasses = testClasses; }