using System; using JetBrains.ProjectModel; using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.Caches; using JetBrains.ReSharper.UnitTestExplorer; namespace MbUnit.ReSharperRunner.Elements { public class MbUnitTestFixtureElement : MbUnitTestElementBase { private readonly string currentAssemblyLocation; private readonly string fixtureType; public MbUnitTestFixtureElement(IUnitTestProvider provider, IProjectModelElement project, string typeName, string assemblyLocation, string fixtureType) : base(provider, null, project, typeName) { currentAssemblyLocation = assemblyLocation; this.fixtureType = fixtureType; } public string AssemblyLocation { get { return currentAssemblyLocation; } } public override string GetTitle() { return new CLRTypeName(GetTypeClrName()).ShortName; } public override IDeclaredElement GetDeclaredElement() { return PsiManager.GetInstance(GetSolution()).GetDeclarationsCache( DeclarationsCacheScope.ProjectScope(GetProject(), false), true).GetTypeElementByCLRName( GetTypeClrName()); } public override string GetKind() { const string attribute = "Attribute"; string kind = fixtureType; if (fixtureType.EndsWith(attribute)) { kind = fixtureType.Substring(0, fixtureType.Length - attribute.Length); } return string.Format("MbUnit {0}", kind); } public override string ToString() { return GetTitle(); } } }