You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.2 KiB
90 lines
2.2 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
|
|
|
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using ICSharpCode.Core; |
|
using ICSharpCode.SharpDevelop.Project; |
|
|
|
namespace ICSharpCode.UnitTesting |
|
{ |
|
public class TestFrameworkDescriptor |
|
{ |
|
Properties properties; |
|
Func<string, object> objectFactory; |
|
ITestFramework testFramework; |
|
List<string> supportedProjectFileExtensions = new List<string>(); |
|
|
|
public TestFrameworkDescriptor(Properties properties, Func<string, object> objectFactory) |
|
{ |
|
this.properties = properties; |
|
this.objectFactory = objectFactory; |
|
|
|
GetSupportedProjectFileExtensions(); |
|
} |
|
|
|
void GetSupportedProjectFileExtensions() |
|
{ |
|
string extensions = properties["supportedProjects"]; |
|
|
|
foreach (string extension in extensions.Split(';')) { |
|
supportedProjectFileExtensions.Add(extension.ToLowerInvariant().Trim()); |
|
} |
|
} |
|
|
|
public string Id { |
|
get { return properties["id"]; } |
|
} |
|
|
|
public ITestFramework TestFramework { |
|
get { |
|
CreateTestFrameworkIfNotCreated(); |
|
return testFramework; |
|
} |
|
} |
|
|
|
void CreateTestFrameworkIfNotCreated() |
|
{ |
|
if (testFramework == null) { |
|
testFramework = (ITestFramework)objectFactory(ClassName); |
|
} |
|
} |
|
|
|
string ClassName { |
|
get { return properties["class"]; } |
|
} |
|
|
|
public bool IsSupportedProject(IProject project) |
|
{ |
|
if (IsSupportedProjectFileExtension(project)) { |
|
return IsSupportedByTestFramework(project); |
|
} |
|
return false; |
|
} |
|
|
|
bool IsSupportedProjectFileExtension(IProject project) |
|
{ |
|
string extension = GetProjectFileExtension(project); |
|
return IsSupportedProjectFileExtension(extension); |
|
} |
|
|
|
string GetProjectFileExtension(IProject project) |
|
{ |
|
if (project != null) { |
|
return Path.GetExtension(project.FileName).ToLowerInvariant(); |
|
} |
|
return null; |
|
} |
|
|
|
bool IsSupportedProjectFileExtension(string extension) |
|
{ |
|
return supportedProjectFileExtensions.Contains(extension); |
|
} |
|
|
|
bool IsSupportedByTestFramework(IProject project) |
|
{ |
|
return TestFramework.IsTestProject(project); |
|
} |
|
} |
|
}
|
|
|