// // // // // $Revision$ // using System; using System.Collections; using System.Collections.Generic; using ICSharpCode.SharpDevelop.Dom; namespace PythonBinding.Tests.Utils { /// /// Mock IProjectContent implementation. /// public class MockProjectContent : IProjectContent { string namespacePassedToNamespaceExistsMethod; List namespacesToAdd = new List(); SearchTypeResult searchTypeResult; bool searchTypeCalled; SearchTypeRequest searchTypeRequest; IClass classToReturnFromGetClass; bool getClassCalled; string getClassName; List classesInProjectContent = new List(); string namespacePassedToGetNamespaceContentsMethod; string classNameForGetClass; bool namespaceExistsCalled; object project; Dictionary> namespaceContents = new Dictionary>(); LanguageProperties language = LanguageProperties.CSharp; List referencedContents = new List(); public MockProjectContent() { } /// /// Gets the namespaces that will be added when the /// AddNamespaceContents method is called. /// public List NamespacesToAdd { get { return namespacesToAdd; } } /// /// Gets whether the NamespaceExists method was called. /// public bool NamespaceExistsCalled { get { return namespaceExistsCalled; } } public string NamespacePassedToNamespaceExistsMethod { get { return namespacePassedToNamespaceExistsMethod; } } /// /// Gets or sets the SearchTypeResult to return from the /// SearchType method. /// public SearchTypeResult SearchTypeResultToReturn { get { return searchTypeResult; } set { searchTypeResult = value; } } /// /// Gets whether the SearchType method was called. /// public bool SearchTypeCalled { get { return searchTypeCalled; } } /// /// Gets the search type request passed to the SearchType method. /// public SearchTypeRequest SearchTypeRequest { get { return searchTypeRequest; } } /// /// Gets or sets the class to return from the GetClass Method. /// public IClass ClassToReturnFromGetClass { get { return classToReturnFromGetClass; } set { classToReturnFromGetClass = value; } } /// /// Gets or sets the class name that needs to match in order /// for the GetClass call to return a class. If nothing is /// specified then every class name matches. /// public string ClassNameForGetClass { get { return classNameForGetClass; } set { classNameForGetClass = value; } } /// /// Gets whether the GetClass method was called. /// public bool GetClassCalled { get { return getClassCalled; } } /// /// Gets the name passed to the GetClass method. /// public string GetClassName { get { return getClassName; } } public string NamespacePassedToGetNamespaceContentsMethod { get { return namespacePassedToGetNamespaceContentsMethod; } } #region IProjectContent public event EventHandler ReferencedContentsChanged; public LanguageProperties Language { get { return language; } } public XmlDoc XmlDoc { get { return null; } } public bool IsUpToDate { get { return true; } } public ICollection Classes { get { throw new NotImplementedException(); } } public ICollection NamespaceNames { get { List names = new List(); foreach (string existingNamespace in namespaceContents.Keys) { names.Add(existingNamespace); } return names; } } public ICollection ReferencedContents { get { return this.referencedContents; } } public IUsing DefaultImports { get { return null; } } public object Project { get { return project; } set { project = value; } } public SystemTypes SystemTypes { get { return new SystemTypes(this); } } public string GetXmlDocumentation(string memberTag) { return null; } public void AddClassToNamespaceList(IClass addClass) { throw new NotImplementedException(); } public void RemoveCompilationUnit(ICompilationUnit oldUnit) { throw new NotImplementedException(); } public void UpdateCompilationUnit(ICompilationUnit oldUnit, ICompilationUnit parserOutput, string fileName) { throw new NotImplementedException(); } public IClass GetClass(string typeName, int typeParameterCount) { getClassName = typeName; getClassCalled = true; // If a class name is specified then only return a class // if we have a match. if (classNameForGetClass != null) { if (typeName == classNameForGetClass) { return classToReturnFromGetClass; } else { return null; } } return classToReturnFromGetClass; } public void AddExistingNamespaceContents(string namespaceName, List items) { namespaceContents.Add(namespaceName, items); } public bool NamespaceExists(string name) { namespaceExistsCalled = true; namespacePassedToNamespaceExistsMethod = name; return namespaceContents.ContainsKey(name); } public List GetNamespaceContents(string nameSpace) { namespacePassedToGetNamespaceContentsMethod = nameSpace; List items; if (namespaceContents.TryGetValue(nameSpace, out items)) { return items; } return new List(); } public IClass GetClass(string typeName, int typeParameterCount, LanguageProperties language, GetClassOptions options) { return GetClass(typeName, typeParameterCount); } public bool NamespaceExists(string name, LanguageProperties language, bool lookInReferences) { throw new NotImplementedException(); } public void AddNamespaceContents(List list, string subNameSpace, LanguageProperties language, bool lookInReferences) { // Add the namespaces to the list. foreach (string ns in namespacesToAdd) { list.Add(new NamespaceEntry(ns)); } // Add the classes in this project content. foreach (IClass c in classesInProjectContent) { list.Add(c); } } /// /// Gets the list of classes that will be added to the list /// when the AddNamespaceContents is called. /// public List ClassesInProjectContent { get { return classesInProjectContent; } } public string SearchNamespace(string name, IClass curType, ICompilationUnit unit, int caretLine, int caretColumn) { // searchNamespaceCalled = true; // namespaceSearchedFor = name; // return searchNamespace; throw new NotImplementedException(); } public SearchTypeResult SearchType(SearchTypeRequest request) { searchTypeCalled = true; searchTypeRequest = request; return searchTypeResult; } public IClass GetClassByReflectionName(string fullMemberName, bool lookInReferences) { throw new NotImplementedException(); } public FilePosition GetPosition(IEntity entity) { throw new NotImplementedException(); } public void Dispose() { throw new NotImplementedException(); } public IList GetAssemblyAttributes() { throw new NotImplementedException(); } #endregion protected virtual void OnReferencedContentsChanged(EventArgs e) { if (ReferencedContentsChanged != null) { ReferencedContentsChanged(this, e); } } public bool InternalsVisibleTo(IProjectContent otherProjectContent) { throw new NotImplementedException(); } public string AssemblyName { get { throw new NotImplementedException(); } } public List GetAllContents() { throw new NotImplementedException(); } public void AddAllContents(List list, LanguageProperties language, bool lookInReferences) { throw new NotImplementedException(); } } }