Browse Source

Change ASP.NET web page and web service project so the OutputPath is set to bin when a new project is created.

pull/1/head
mrward 15 years ago
parent
commit
7b72aa9d78
  1. 9
      data/templates/project/CSharp/WebService.xpt
  2. 10
      data/templates/project/CSharp/WebpageProject.xpt
  3. 117
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveBuiltInRoundMethodTestFixture.cs
  4. 57
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs
  5. 61
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs
  6. 47
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveExitMethodFromSysImportExitAsMyExitTestFixture.cs
  7. 52
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs
  8. 45
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooWindowsWithImportSystemAsFooTestFixture.cs
  9. 55
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFromImportTestFixture.cs
  10. 55
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFromMathImportedMathModuleCompletionItemsTestFixture.cs
  11. 101
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs
  12. 37
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodFromUnknownImportAllTestFixture.cs
  13. 36
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodWhenFromImportIsUnknownTestFixture.cs
  14. 36
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodWhenImportIsUnknownTestFixture.cs
  15. 136
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleExitMethodTestFixture.cs
  16. 42
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleImportedAsMySysTestFixture.cs
  17. 36
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleUnknownMethodTestFixture.cs
  18. 111
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs
  19. 59
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemImportTestFixture.cs
  20. 68
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemImportedAsMySystemTestFixture.cs
  21. 67
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceTestFixture.cs
  22. 44
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs
  23. 45
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWindowsFormsWithImportSystemTestFixture.cs
  24. 45
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWindowsWithImportSystemTestFixture.cs
  25. 39
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWithImportSystemWindowsTestFixture.cs
  26. 63
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTanMethodFromMathImportAllTestFixture.cs
  27. 60
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTanMethodFromMathImportCosAndTanTestFixture.cs
  28. 41
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTestFixtureBase.cs
  29. 52
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs
  30. 52
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs
  31. 43
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveUnknownNamespaceTestFixture.cs

9
data/templates/project/CSharp/WebService.xpt

@ -31,9 +31,16 @@ @@ -31,9 +31,16 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<OutputPath>bin\</OutputPath>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup configuration="Debug">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup configuration="Release">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Files>
<File name="Soap.cs" DependentUpon="Default.asmx"><![CDATA[${StandardHeader.C#}

10
data/templates/project/CSharp/WebpageProject.xpt

@ -31,10 +31,16 @@ @@ -31,10 +31,16 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<OutputPath>bin\</OutputPath>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup configuration="Debug">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<PropertyGroup configuration="Release">
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Files>
<!--*************************************************************************-->
<File name=".\Default.aspx.cs" DependentUpon="Default.aspx"><![CDATA[${StandardHeader.C#}

117
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveBuiltInRoundMethodTestFixture.cs

@ -1,117 +0,0 @@ @@ -1,117 +0,0 @@
// 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;
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 ResolveBuiltInRoundMethodTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("round", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"round\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsMethodGroupResolveResult()
{
Assert.IsTrue(resolveResult is MethodGroupResolveResult);
}
[Test]
public void ResolveResultMethodNameIsRound()
{
Assert.AreEqual("round", MethodResolveResult.Name);
}
MethodGroupResolveResult MethodResolveResult {
get { return (MethodGroupResolveResult)resolveResult; }
}
[Test]
public void ResolveResultContainingTypeHasTwoRoundMethods()
{
List<IMethod> exitMethods = GetRoundMethods();
Assert.AreEqual(2, exitMethods.Count);
}
List<IMethod> GetRoundMethods()
{
return GetRoundMethods(-1);
}
List<IMethod> GetRoundMethods(int parameterCount)
{
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods();
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("round", parameterCount, methods.ToArray());
}
[Test]
public void BothRoundMethodsArePublic()
{
foreach (IMethod method in GetRoundMethods()) {
Assert.IsTrue(method.IsPublic);
}
}
[Test]
public void BothRoundMethodsHaveClassWithNameOfSys()
{
foreach (IMethod method in GetRoundMethods()) {
Assert.AreEqual("__builtin__", method.DeclaringType.Name);
}
}
[Test]
public void OneRoundMethodHasTwoParameters()
{
int parameterCount = 2;
Assert.AreEqual(1, GetRoundMethods(parameterCount).Count);
}
[Test]
public void RoundMethodParameterNameIsNumber()
{
IParameter parameter = GetFirstRoundMethodParameter();
Assert.AreEqual("number", parameter.Name);
}
IParameter GetFirstRoundMethodParameter()
{
int parameterCount = 1;
List<IMethod> methods = GetRoundMethods(parameterCount);
IMethod method = methods[0];
return method.Parameters[0];
}
[Test]
public void RoundMethodParameterReturnTypeIsDouble()
{
IParameter parameter = GetFirstRoundMethodParameter();
Assert.AreEqual("Double", parameter.ReturnType.Name);
}
[Test]
public void RoundMethodParameterConvertedToStringUsingAmbienceReturnsDoubleNumberString()
{
IAmbience ambience = new CSharpAmbience();
string text = ambience.Convert(GetFirstRoundMethodParameter());
Assert.AreEqual("double number", text);
}
}
}

57
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs

@ -1,57 +0,0 @@ @@ -1,57 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
using UnitTesting.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";
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
projectContent.AddExistingNamespaceContents("System", namespaceItems);
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"));
}
}
}

61
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Tests that the expression "Console.WriteLine" is correctly
/// resolved.
/// </summary>
[TestFixture]
public class ResolveConsoleWriteLineTestFixture : ResolveTestFixtureBase
{
MockClass systemConsoleClass;
protected override ExpressionResult GetExpressionResult()
{
systemConsoleClass = new MockClass(projectContent, "System.Console");
projectContent.ClassToReturnFromGetClass = systemConsoleClass;
projectContent.ClassNameForGetClass = "Console";
return new ExpressionResult("Console.WriteLine", new DomRegion(2, 2), null, null);
}
protected override string GetPythonScript()
{
return
"import System\r\n" +
"Console.WriteLine\r\n";
}
[Test]
public void ResolveResultExists()
{
Assert.IsNotNull(resolveResult);
}
/// <summary>
/// Gets the class name used in IProjectContent.GetClass call.
/// </summary>
[Test]
public void GetClassName()
{
Assert.AreEqual("Console", projectContent.GetClassName);
}
[Test]
public void MethodNameResolveIsWriteLine()
{
MethodGroupResolveResult methodResolveResult = (MethodGroupResolveResult)resolveResult;
Assert.AreEqual("WriteLine", methodResolveResult.Name);
}
}
}

47
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveExitMethodFromSysImportExitAsMyExitTestFixture.cs

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
// 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;
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 ResolveExitMethodFromSysImportExitAsMyExitTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("myexit", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from sys import exit as myexit\r\n" +
"myexit\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsMethodGroupResolveResult()
{
Assert.IsTrue(resolveResult is MethodGroupResolveResult);
}
[Test]
public void ResolveResultMethodNameIsExit()
{
Assert.AreEqual("exit", MethodResolveResult.Name);
}
MethodGroupResolveResult MethodResolveResult {
get { return (MethodGroupResolveResult)resolveResult; }
}
}
}

52
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveTextBoxFromSystemWindowsFormsImportedAsFooTestFixture : 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("Foo.TextBox", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"import System.Windows.Forms as Foo\r\n" +
"Foo.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; }
}
}
}

45
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooWindowsWithImportSystemAsFooTestFixture.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveFooWindowsWithImportSystemAsFooTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
MockProjectContent referencedContent = new MockProjectContent();
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
referencedContent.AddExistingNamespaceContents("System.Windows.Forms", namespaceItems);
projectContent.ReferencedContents.Add(referencedContent);
return new ExpressionResult("Foo.Windows");
}
protected override string GetPythonScript()
{
return
"import System as Foo\r\n" +
"Foo.Windows\r\n";
}
NamespaceResolveResult NamespaceResolveResult {
get { return resolveResult as NamespaceResolveResult; }
}
[Test]
public void NamespaceResolveResultHasSystemWindowsNamespace()
{
Assert.AreEqual("System.Windows", NamespaceResolveResult.Name);
}
}
}

55
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFromImportTestFixture.cs

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Tests that the PythonResolver resolves "from System" to
/// a namespace.
/// </summary>
[TestFixture]
public class ResolveFromImportTestFixture
{
PythonResolver resolver;
MockProjectContent mockProjectContent;
PythonImportModuleResolveResult resolveResult;
[TestFixtureSetUp]
public void SetUpFixture()
{
resolver = new PythonResolver();
mockProjectContent = new MockProjectContent();
DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent);
cu.ErrorsDuringCompile = true;
cu.FileName = @"C:\Projects\Test\test.py";
ParseInformation parseInfo = new ParseInformation(cu);
string python = "from System";
PythonExpressionFinder finder = new PythonExpressionFinder();
ExpressionResult expressionResult = finder.FindExpression(python, python.Length);
resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as PythonImportModuleResolveResult;
}
[Test]
public void NamespaceResolveResultFound()
{
Assert.IsNotNull(resolveResult);
}
[Test]
public void NamespaceName()
{
Assert.AreEqual("System", resolveResult.Name);
}
}
}

55
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFromMathImportedMathModuleCompletionItemsTestFixture.cs

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveFromMathImportedMathModuleCompletionItemsTestFixture : ResolveTestFixtureBase
{
List<ICompletionEntry> GetCompletionResults()
{
return resolveResult.GetCompletionData(projectContent);
}
protected override ExpressionResult GetExpressionResult()
{
string code = GetPythonScript();
PythonExpressionFinder finder = new PythonExpressionFinder();
return finder.FindExpression(code, code.Length);
}
protected override string GetPythonScript()
{
return "from math import";
}
[Test]
public void CompletionResultsContainCosMethodFromMathModule()
{
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("cos", GetCompletionResults());
Assert.IsNotNull(method);
}
[Test]
public void ExpressionResultContextShowItemReturnsTrueForIMethod()
{
MockProjectContent projectContent = new MockProjectContent();
DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent);
DefaultClass c = new DefaultClass(unit, "MyClass");
DefaultMethod method = new DefaultMethod(c, "Test");
Assert.IsTrue(expressionResult.Context.ShowEntry(method));
}
}
}

101
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs

@ -1,101 +0,0 @@ @@ -1,101 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Given code:
///
/// a = Class1()
///
/// Check that the type of "a" can be obtained by the resolver.
/// </summary>
[TestFixture]
[Ignore("Disabled local variable resolution for SD 3.0")]
public class ResolveLocalClassInstanceTestFixture
{
PythonResolver resolver;
ICSharpCode.Scripting.Tests.Utils.MockProjectContent mockProjectContent;
LocalResolveResult resolveResult;
MockClass testClass;
ICompilationUnit compilationUnit;
[TestFixtureSetUp]
public void SetUpFixture()
{
resolver = new PythonResolver();
mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent();
testClass = new MockClass(mockProjectContent, "Test.Test1");
mockProjectContent.ClassesInProjectContent.Add(testClass);
mockProjectContent.ClassToReturnFromGetClass = testClass;
mockProjectContent.ClassNameForGetClass = "Test.Test1";
compilationUnit = new DefaultCompilationUnit(mockProjectContent);
compilationUnit.FileName = @"C:\Projects\Test\test.py";
ParseInformation parseInfo = new ParseInformation(compilationUnit);
string python = "a = Test1()\r\n" +
"a";
ExpressionResult expressionResult = new ExpressionResult("a", new DomRegion(2, 1), null, null);
resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as LocalResolveResult;
}
[Test]
public void GetTypeOfInstance()
{
string code = "a = Class1()";
PythonVariableResolver resolver = new PythonVariableResolver();
Assert.AreEqual("Class1", resolver.Resolve("a", @"C:\Projects\Test\Test.py", code));
}
/// <summary>
/// Tests that the NameExpression in the resolver is reset so the second assignment
/// does not override the first.
/// </summary>
[Test]
public void DifferentTypeCreatedLast()
{
string code = "a = Class1()\r\n" +
"b = Class2()";
PythonVariableResolver resolver = new PythonVariableResolver();
Assert.AreEqual("Class1", resolver.Resolve("a", @"C:\Projects\Test\Test.py", code));
}
[Test]
public void StringAssignmentShouldNotResolve()
{
string code = "a = \"test\"";
PythonVariableResolver resolver = new PythonVariableResolver();
Assert.AreEqual(null, resolver.Resolve("a", @"C:\Projects\Test\Test.py", code));
}
[Test]
public void NullCodeShouldNotResolve()
{
PythonVariableResolver resolver = new PythonVariableResolver();
Assert.AreEqual(null, resolver.Resolve("a", @"C:\Projects\Test\Test.py", null));
}
[Test]
public void ResolveResultIsLocalResolveResult()
{
Assert.IsNotNull(resolveResult);
}
[Test]
public void ResolveResultVariableName()
{
Assert.AreEqual(resolveResult.VariableName, "a");
}
}
}

37
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodFromUnknownImportAllTestFixture.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
// 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;
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 ResolveMethodFromUnknownImportAllTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("methodcall", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from unknown import *\r\n" +
"methodcall\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsNull()
{
Assert.IsNull(resolveResult);
}
}
}

36
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodWhenFromImportIsUnknownTestFixture.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveMethodWhenFromImportIsUnknownTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("methodcall", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from unknown import methodcall\r\n" +
"methodcall\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsNull()
{
Assert.IsNull(resolveResult);
}
}
}

36
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMethodWhenImportIsUnknownTestFixture.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveMethodWhenImportIsUnknownTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("unknown.methodcall", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from unknown import methodcall\r\n" +
"unknown.methodcall\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsNull()
{
Assert.IsNull(resolveResult);
}
}
}

136
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleExitMethodTestFixture.cs

@ -1,136 +0,0 @@ @@ -1,136 +0,0 @@
// 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;
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 ResolveSysModuleExitMethodTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("sys.exit", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"import sys\r\n" +
"sys.exit\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsMethodGroupResolveResult()
{
Assert.IsTrue(resolveResult is MethodGroupResolveResult);
}
[Test]
public void ResolveResultMethodNameIsExit()
{
Assert.AreEqual("exit", MethodResolveResult.Name);
}
MethodGroupResolveResult MethodResolveResult {
get { return (MethodGroupResolveResult)resolveResult; }
}
[Test]
public void ResolveResultContainingTypeHasTwoExitMethods()
{
List<IMethod> exitMethods = GetExitMethods();
Assert.AreEqual(2, exitMethods.Count);
}
List<IMethod> GetExitMethods()
{
return GetExitMethods(-1);
}
List<IMethod> GetExitMethods(int parameterCount)
{
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods();
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("exit", parameterCount, methods.ToArray());
}
[Test]
public void BothExitMethodsArePublic()
{
foreach (IMethod method in GetExitMethods()) {
Assert.IsTrue(method.IsPublic);
}
}
[Test]
public void BothExitMethodsHaveClassWithNameOfSys()
{
foreach (IMethod method in GetExitMethods()) {
Assert.AreEqual("sys", method.DeclaringType.Name);
}
}
[Test]
public void OneExitMethodHasOneParameter()
{
int parameterCount = 1;
Assert.AreEqual(1, GetExitMethods(parameterCount).Count);
}
[Test]
public void ExitMethodParameterNameIsCode()
{
IParameter parameter = GetFirstExitMethodParameter();
Assert.AreEqual("code", parameter.Name);
}
IParameter GetFirstExitMethodParameter()
{
int parameterCount = 1;
List<IMethod> methods = GetExitMethods(parameterCount);
IMethod method = methods[0];
return method.Parameters[0];
}
[Test]
public void ExitMethodParameterReturnTypeIsObject()
{
IParameter parameter = GetFirstExitMethodParameter();
Assert.AreEqual("Object", parameter.ReturnType.Name);
}
[Test]
public void ExitMethodParameterConvertedToStringUsingAmbienceReturnsObjectCodeString()
{
IAmbience ambience = new CSharpAmbience();
string text = ambience.Convert(GetFirstExitMethodParameter());
Assert.AreEqual("object code", text);
}
[Test]
public void ExitMethodReturnTypeConvertedToStringUsingAmbienceReturnsVoid()
{
IAmbience ambience = new CSharpAmbience();
List<IMethod> methods = GetExitMethods();
IReturnType returnType = methods[0].ReturnType;
string text = ambience.Convert(returnType);
Assert.AreEqual("void", text);
}
[Test]
public void MethodGroupContainingTypeHasTwoExitMethods()
{
IReturnType returnType = MethodResolveResult.ContainingType;
List<IMethod> methods = PythonCompletionItemsHelper.FindAllMethodsFromCollection("exit", returnType.GetMethods());
Assert.AreEqual(2, methods.Count);
}
}
}

42
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleImportedAsMySysTestFixture.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSysModuleImportedAsMySysTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("mysys", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"import sys as mysys\r\n" +
"mysys\r\n" +
"\r\n";
}
[Test]
public void ResolveResultContainsExitMethod()
{
List<ICompletionEntry> items = GetCompletionItems();
IMethod method = PythonCompletionItemsHelper.FindMethodFromCollection("exit", items);
Assert.IsNotNull(method);
}
List<ICompletionEntry> GetCompletionItems()
{
return resolveResult.GetCompletionData(projectContent);
}
}
}

36
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSysModuleUnknownMethodTestFixture.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSysModuleUnknownMethodTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("sys.unknown", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"import sys\r\n" +
"sys.unknown\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsNull()
{
Assert.IsNull(resolveResult);
}
}
}

111
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs

@ -1,111 +0,0 @@ @@ -1,111 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Tests the PythonResolver correctly resolves the expression:
/// "System.Console"
/// </summary>
[TestFixture]
public class ResolveSystemConsoleTestFixture
{
PythonResolver resolver;
ICSharpCode.Scripting.Tests.Utils.MockProjectContent mockProjectContent;
ResolveResult resolveResult;
MockClass testClass;
ICompilationUnit compilationUnit;
MockClass systemConsoleClass;
ResolveResult invalidMostRecentCompilationUnitResolveResult;
[TestFixtureSetUp]
public void SetUpFixture()
{
resolver = new PythonResolver();
mockProjectContent = new ICSharpCode.Scripting.Tests.Utils.MockProjectContent();
systemConsoleClass = new MockClass(mockProjectContent, "System.Console");
mockProjectContent.ClassToReturnFromGetClass = systemConsoleClass;
compilationUnit = CreateCompilationUnit(mockProjectContent);
ParseInformation parseInfo = new ParseInformation(compilationUnit);
string python = GetPythonScript();
ExpressionResult expressionResult = new ExpressionResult("System.Console", new DomRegion(3, 2), null, null);
resolveResult = resolver.Resolve(expressionResult, parseInfo, python);
// Check that the best compilation unit is used and the resolve
// still works.
invalidMostRecentCompilationUnitResolveResult = resolver.Resolve(expressionResult, parseInfo, python);
}
[Test]
public void ResolveResultExists()
{
Assert.IsNotNull(resolveResult);
}
[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);
}
[Test]
public void ResolvedClassWithInvalidMostRecentCompilationUnit()
{
TypeResolveResult typeResolveResult = invalidMostRecentCompilationUnitResolveResult as TypeResolveResult;
Assert.AreEqual(systemConsoleClass, typeResolveResult.ResolvedClass);
}
/// <summary>
/// Returns the Python script that will be used for testing.
/// </summary>
protected virtual string GetPythonScript()
{
return "import System\r\n" +
"class Test:\r\n" +
"\tdef __init__(self):\r\n" +
"\t\tSystem.Console\r\n";
}
/// <summary>
/// Creates a compilation unit with one class called Test.
/// </summary>
protected virtual ICompilationUnit CreateCompilationUnit(IProjectContent projectContent)
{
ICompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent);
testClass = new MockClass(projectContent, "Test");
compilationUnit.Classes.Add(testClass);
return compilationUnit;
}
}
}

59
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemImportTestFixture.cs

@ -1,59 +0,0 @@ @@ -1,59 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Tests that the PythonResolver resolves "import System" to
/// a namespace.
/// </summary>
[TestFixture]
public class ResolveSystemImportTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
string code = GetPythonScript();
PythonExpressionFinder finder = new PythonExpressionFinder();
return finder.FindExpression(code, code.Length);
}
protected override string GetPythonScript()
{
return "import System";
}
[Test]
public void NamespaceResolveResultFound()
{
Assert.IsNotNull(resolveResult);
}
[Test]
public void NamespaceName()
{
PythonImportModuleResolveResult importResolveResult = (PythonImportModuleResolveResult)resolveResult;
Assert.AreEqual("System", importResolveResult.Name);
}
[Test]
public void ExpressionResultContextShowItemReturnsTrueForNamespaceEntry()
{
NamespaceEntry entry = new NamespaceEntry("abc");
Assert.IsTrue(expressionResult.Context.ShowEntry(entry));
}
[Test]
public void ExpressionResultContextShowItemReturnsFalseForNull()
{
Assert.IsFalse(expressionResult.Context.ShowEntry(null));
}
}
}

68
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemImportedAsMySystemTestFixture.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSystemImportedAsMySystemTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
DefaultClass consoleClass = new DefaultClass(compilationUnit, "System.Console");
namespaceItems.Add(consoleClass);
projectContent.AddExistingNamespaceContents("System", namespaceItems);
return new ExpressionResult("MySystem", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"import System as MySystem\r\n" +
"MySystem.\r\n" +
"\r\n";
}
[Test]
public void ResolveResultContainsConsoleClass()
{
List<ICompletionEntry> items = GetCompletionItems();
IClass consoleClass = PythonCompletionItemsHelper.FindClassFromCollection("Console", items);
Assert.IsNotNull(consoleClass);
}
List<ICompletionEntry> GetCompletionItems()
{
return resolveResult.GetCompletionData(projectContent);
}
[Test]
public void NamespaceResolveResultNameIsSystem()
{
NamespaceResolveResult namespaceResolveResult = resolveResult as NamespaceResolveResult;
Assert.AreEqual("System", namespaceResolveResult.Name);
}
[Test]
public void MockProjectContentSystemNamespaceContentsIncludesConsoleClass()
{
List<ICompletionEntry> items = projectContent.GetNamespaceContents("System");
IClass consoleClass = PythonCompletionItemsHelper.FindClassFromCollection("Console", items);
Assert.IsNotNull(consoleClass);
}
[Test]
public void MockProjectContentNamespaceExistsReturnsTrueForSystem()
{
Assert.IsTrue(projectContent.NamespaceExists("System"));
}
}
}

67
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceTestFixture.cs

@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
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:
/// "System"
/// </summary>
[TestFixture]
public class ResolveSystemNamespaceTestFixture
{
PythonResolver resolver;
MockProjectContent mockProjectContent;
NamespaceResolveResult resolveResult;
[TestFixtureSetUp]
public void SetUpFixture()
{
resolver = new PythonResolver();
mockProjectContent = new MockProjectContent();
mockProjectContent.AddExistingNamespaceContents("System", new List<ICompletionEntry>());
string python =
"import System\r\n" +
"class Test:\r\n" +
" def __init__(self):\r\n" +
" System.\r\n";
PythonParser parser = new PythonParser();
string fileName = @"C:\Projects\Test\test.py";
DefaultCompilationUnit cu = parser.Parse(mockProjectContent, fileName, python) as DefaultCompilationUnit;
cu.ErrorsDuringCompile = true;
ParseInformation parseInfo = new ParseInformation(cu);
ExpressionResult expressionResult = new ExpressionResult("System", new DomRegion(4, 2), null, null);
resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as NamespaceResolveResult;
}
[Test]
public void NamespaceExistsCalled()
{
Assert.IsTrue(mockProjectContent.NamespaceExistsCalled);
}
[Test]
public void NamespaceSearchedFor()
{
Assert.AreEqual("System", mockProjectContent.NamespacePassedToNamespaceExistsMethod);
}
[Test]
public void NamespaceResolveResultHasSystemNamespace()
{
Assert.AreEqual("System", resolveResult.Name);
}
}
}

44
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
using UnitTesting.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSystemNamespaceWithMissingImportTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
MockClass systemConsoleClass = new MockClass(projectContent, "System.Console");
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
namespaceItems.Add(systemConsoleClass);
projectContent.AddExistingNamespaceContents("System", namespaceItems);
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"));
}
}
}

45
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWindowsFormsWithImportSystemTestFixture.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSystemWindowsFormsWithImportSystemTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
MockProjectContent referencedContent = new MockProjectContent();
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
referencedContent.AddExistingNamespaceContents("System.Windows.Forms", namespaceItems);
projectContent.ReferencedContents.Add(referencedContent);
return new ExpressionResult("System.Windows.Forms");
}
protected override string GetPythonScript()
{
return
"import System\r\n" +
"System.Windows.Forms\r\n";
}
NamespaceResolveResult NamespaceResolveResult {
get { return resolveResult as NamespaceResolveResult; }
}
[Test]
public void NamespaceResolveResultHasSystemNamespace()
{
Assert.AreEqual("System.Windows.Forms", NamespaceResolveResult.Name);
}
}
}

45
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWindowsWithImportSystemTestFixture.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSystemWindowsWithImportSystemTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
MockProjectContent referencedContent = new MockProjectContent();
List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
referencedContent.AddExistingNamespaceContents("System.Windows.Forms", namespaceItems);
projectContent.ReferencedContents.Add(referencedContent);
return new ExpressionResult("System.Windows");
}
protected override string GetPythonScript()
{
return
"import System\r\n" +
"System.Windows\r\n";
}
NamespaceResolveResult NamespaceResolveResult {
get { return resolveResult as NamespaceResolveResult; }
}
[Test]
public void NamespaceResolveResultHasSystemWindowsNamespace()
{
Assert.AreEqual("System.Windows", NamespaceResolveResult.Name);
}
}
}

39
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemWithImportSystemWindowsTestFixture.cs

@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
// 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;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
[TestFixture]
public class ResolveSystemWithImportSystemWindowsTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("System");
}
protected override string GetPythonScript()
{
return
"import System.Windows\r\n" +
"System\r\n";
}
NamespaceResolveResult NamespaceResolveResult {
get { return resolveResult as NamespaceResolveResult; }
}
[Test]
public void NamespaceResolveResultHasSystemNamespace()
{
Assert.AreEqual("System", NamespaceResolveResult.Name);
}
}
}

63
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTanMethodFromMathImportAllTestFixture.cs

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
// 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;
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 ResolveTanMethodFromMathImportAllTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("tan", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from sys import *\r\n" +
"from math import *\r\n" +
"from socket import *\r\n" +
"\r\n" +
"tan\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsMethodGroupResolveResult()
{
Assert.IsTrue(resolveResult is MethodGroupResolveResult);
}
[Test]
public void ResolveResultMethodNameIsTan()
{
Assert.AreEqual("tan", MethodResolveResult.Name);
}
MethodGroupResolveResult MethodResolveResult {
get { return (MethodGroupResolveResult)resolveResult; }
}
[Test]
public void ResolveResultContainingTypeHasOneTanMethods()
{
List<IMethod> tanMethods = GetTanMethods();
Assert.AreEqual(1, tanMethods.Count);
}
List<IMethod> GetTanMethods()
{
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods();
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("tan", -1, methods.ToArray());
}
}
}

60
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTanMethodFromMathImportCosAndTanTestFixture.cs

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
// 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;
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 ResolveTanMethodFromMathImportCosAndTanTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
return new ExpressionResult("tan", ExpressionContext.Default);
}
protected override string GetPythonScript()
{
return
"from math import cos, tan\r\n" +
"tan\r\n" +
"\r\n";
}
[Test]
public void ResolveResultIsMethodGroupResolveResult()
{
Assert.IsTrue(resolveResult is MethodGroupResolveResult);
}
[Test]
public void ResolveResultMethodNameIsTan()
{
Assert.AreEqual("tan", MethodResolveResult.Name);
}
MethodGroupResolveResult MethodResolveResult {
get { return (MethodGroupResolveResult)resolveResult; }
}
[Test]
public void ResolveResultContainingTypeHasOneTanMethods()
{
List<IMethod> tanMethods = GetTanMethods();
Assert.AreEqual(1, tanMethods.Count);
}
List<IMethod> GetTanMethods()
{
List<IMethod> methods = MethodResolveResult.ContainingType.GetMethods();
return PythonCompletionItemsHelper.FindAllMethodsFromCollection("tan", -1, methods.ToArray());
}
}
}

41
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTestFixtureBase.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
public abstract class ResolveTestFixtureBase
{
protected ICompilationUnit compilationUnit;
protected MockProjectContent projectContent;
protected PythonResolver resolver;
protected ResolveResult resolveResult;
protected ParseInformation parseInfo;
protected ExpressionResult expressionResult;
[SetUp]
public void InitBase()
{
projectContent = new MockProjectContent();
PythonParser parser = new PythonParser();
string fileName = @"C:\projects\test\test.py";
compilationUnit = parser.Parse(projectContent, fileName, GetPythonScript());
parseInfo = new ParseInformation(compilationUnit);
resolver = new PythonResolver();
expressionResult = GetExpressionResult();
resolveResult = resolver.Resolve(expressionResult, parseInfo, GetPythonScript());
}
protected abstract ExpressionResult GetExpressionResult();
protected abstract string GetPythonScript();
}
}

52
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
using UnitTesting.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; }
}
}
}

52
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// 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;
using System.Collections.Generic;
using ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.CSharp;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
using UnitTesting.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; }
}
}
}

43
src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveUnknownNamespaceTestFixture.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// 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 ICSharpCode.PythonBinding;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
using PythonBinding.Tests;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Resolver
{
/// <summary>
/// Tests the PythonResolver does not return a namespace resolve result for
/// an unknown namespace.
/// </summary>
[TestFixture]
public class ResolveUnknownNamespaceTestFixture : ResolveTestFixtureBase
{
protected override ExpressionResult GetExpressionResult()
{
projectContent.AddExistingNamespaceContents("System", new List<ICompletionEntry>());
return new ExpressionResult("Unknown", new DomRegion(3, 2), null, null);
}
protected override string GetPythonScript()
{
return
"import System\r\n" +
"class Test:\r\n" +
" def __init__(self):\r\n" +
" Unknown\r\n";
}
[Test]
public void ResolveResultDoesNotExist()
{
Assert.IsNull(resolveResult);
}
}
}
Loading…
Cancel
Save