Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5472 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
12 changed files with 333 additions and 104 deletions
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveFromSystemImportEverythingFixture : ResolveTestFixtureBase |
||||
{ |
||||
MockClass consoleClass; |
||||
|
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
consoleClass = new MockClass(projectContent, "System.Console"); |
||||
projectContent.ClassToReturnFromGetClass = consoleClass; |
||||
projectContent.ClassNameForGetClass = "System.Console"; |
||||
|
||||
projectContent.AddExistingNamespaceContents("System", new ArrayList()); |
||||
|
||||
return new ExpressionResult("Console", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from System import *\r\n" + |
||||
"Console\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultResolvedClassIsConsoleClass() |
||||
{ |
||||
Assert.AreEqual(consoleClass, TypeResolveResult.ResolvedClass); |
||||
} |
||||
|
||||
TypeResolveResult TypeResolveResult { |
||||
get { return (TypeResolveResult)resolveResult; } |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectContentNamespaceExistsReturnsTrueForSystem() |
||||
{ |
||||
Assert.IsTrue(projectContent.NamespaceExists("System")); |
||||
} |
||||
} |
||||
} |
@ -1,85 +0,0 @@
@@ -1,85 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
/// <summary>
|
||||
/// Tests the PythonResolver correctly resolves the expression:
|
||||
/// "Console." when the System namespace is imported.
|
||||
/// </summary>
|
||||
[TestFixture] |
||||
public class ResolveConsoleTestFixture |
||||
{ |
||||
PythonResolver resolver; |
||||
MockProjectContent mockProjectContent; |
||||
ResolveResult resolveResult; |
||||
MockClass testClass; |
||||
ICompilationUnit compilationUnit; |
||||
MockClass systemConsoleClass; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUpFixture() |
||||
{ |
||||
resolver = new PythonResolver(); |
||||
ParseInformation parseInfo = new ParseInformation(); |
||||
mockProjectContent = new MockProjectContent(); |
||||
|
||||
// Do not return any class from GetClass call. This method
|
||||
// will not return anything in the real class since the
|
||||
// type is not fully qualified with its namespace.
|
||||
mockProjectContent.ClassToReturnFromGetClass = null; |
||||
|
||||
systemConsoleClass = new MockClass(mockProjectContent, "System.Console"); |
||||
mockProjectContent.ClassesInProjectContent.Add(systemConsoleClass); |
||||
|
||||
compilationUnit = new DefaultCompilationUnit(mockProjectContent) { ErrorsDuringCompile = true }; |
||||
testClass = new MockClass(compilationUnit, "Test"); |
||||
compilationUnit.Classes.Add(testClass); |
||||
parseInfo.SetCompilationUnit(compilationUnit); |
||||
|
||||
string python = "import System\r\n" + |
||||
"class Test:\r\n" + |
||||
"\tdef __init__(self):\r\n" + |
||||
"\tConsole\r\n"; |
||||
ExpressionResult expressionResult = new ExpressionResult("Console", new DomRegion(3, 7), null, null); |
||||
resolveResult = resolver.Resolve(expressionResult, parseInfo, python); |
||||
} |
||||
|
||||
[Test] |
||||
public void IsTypeResolveResult() |
||||
{ |
||||
Assert.IsInstanceOf(typeof(TypeResolveResult), resolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolvedClass() |
||||
{ |
||||
TypeResolveResult typeResolveResult = resolveResult as TypeResolveResult; |
||||
Assert.AreEqual(systemConsoleClass, typeResolveResult.ResolvedClass); |
||||
} |
||||
//
|
||||
// [Test]
|
||||
// public void IsGetClassCalled()
|
||||
// {
|
||||
// Assert.IsTrue(mockProjectContent.GetClassCalled);
|
||||
// }
|
||||
//
|
||||
// [Test]
|
||||
// public void GetClassName()
|
||||
// {
|
||||
// Assert.AreEqual("System.Console", mockProjectContent.GetClassName);
|
||||
// }
|
||||
} |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveSystemNamespaceWithMissingImportTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
MockClass systemConsoleClass = new MockClass(projectContent, "System.Console"); |
||||
ArrayList items = new ArrayList(); |
||||
items.Add(systemConsoleClass); |
||||
projectContent.AddExistingNamespaceContents("System", items); |
||||
|
||||
return new ExpressionResult("System", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return "System\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsNullSinceSystemNamespaceIsNotImported() |
||||
{ |
||||
Assert.IsNull(resolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ProjectContentNamespaceExistsReturnsTrueForSystemNamespace() |
||||
{ |
||||
Assert.IsTrue(projectContent.NamespaceExists("System")); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
MockClass textBoxClass = new MockClass(projectContent, "System.Windows.Forms.TextBox"); |
||||
projectContent.ClassToReturnFromGetClass = textBoxClass; |
||||
projectContent.ClassNameForGetClass = "System.Windows.Forms.TextBox"; |
||||
|
||||
return new ExpressionResult("TextBox", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from System.Windows.Forms import TextBox\r\n" + |
||||
"TextBox\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsTypeResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is TypeResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultResolveClassNameIsTextBox() |
||||
{ |
||||
Assert.AreEqual("TextBox", TypeResolveResult.ResolvedClass.Name); |
||||
} |
||||
|
||||
TypeResolveResult TypeResolveResult { |
||||
get { return (TypeResolveResult)resolveResult; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.PythonBinding; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.CSharp; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Resolver |
||||
{ |
||||
[TestFixture] |
||||
public class ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture : ResolveTestFixtureBase |
||||
{ |
||||
protected override ExpressionResult GetExpressionResult() |
||||
{ |
||||
MockClass textBoxClass = new MockClass(projectContent, "System.Windows.Forms.TextBox"); |
||||
projectContent.ClassToReturnFromGetClass = textBoxClass; |
||||
projectContent.ClassNameForGetClass = "System.Windows.Forms.TextBox"; |
||||
|
||||
return new ExpressionResult("MyTextBox", ExpressionContext.Default); |
||||
} |
||||
|
||||
protected override string GetPythonScript() |
||||
{ |
||||
return |
||||
"from System.Windows.Forms import TextBox as MyTextBox\r\n" + |
||||
"MyTextBox\r\n" + |
||||
"\r\n"; |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultIsTypeResolveResult() |
||||
{ |
||||
Assert.IsTrue(resolveResult is TypeResolveResult); |
||||
} |
||||
|
||||
[Test] |
||||
public void ResolveResultResolveClassNameIsTextBox() |
||||
{ |
||||
Assert.AreEqual("TextBox", TypeResolveResult.ResolvedClass.Name); |
||||
} |
||||
|
||||
TypeResolveResult TypeResolveResult { |
||||
get { return (TypeResolveResult)resolveResult; } |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue