Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4700 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
3 changed files with 138 additions and 24 deletions
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
// <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.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.PythonBinding; |
||||
using IronPython.Compiler.Ast; |
||||
using NUnit.Framework; |
||||
using PythonBinding.Tests.Utils; |
||||
|
||||
namespace PythonBinding.Tests.Designer |
||||
{ |
||||
[TestFixture] |
||||
public class DeserializeCallParametersTestFixture |
||||
{ |
||||
PythonCodeDeserializer deserializer; |
||||
MockComponentCreator componentCreator; |
||||
|
||||
[SetUp] |
||||
public void Init() |
||||
{ |
||||
componentCreator = new MockComponentCreator(); |
||||
MockDesignerLoaderHost mockDesignerLoaderHost = new MockDesignerLoaderHost(); |
||||
deserializer = new PythonCodeDeserializer(componentCreator); |
||||
} |
||||
|
||||
[Test] |
||||
public void NegativeIntegerParameter() |
||||
{ |
||||
List<object> expectedArgs = new List<object>(); |
||||
expectedArgs.Add(-1); |
||||
|
||||
string code = "TestClass(-1)"; |
||||
CallExpression callExpression = PythonParserHelper.GetCallExpression(code); |
||||
List<object> args = deserializer.GetArguments(callExpression); |
||||
|
||||
Assert.AreEqual(expectedArgs, args); |
||||
} |
||||
|
||||
[Test] |
||||
public void EnumParameter() |
||||
{ |
||||
List<object> expectedArgs = new List<object>(); |
||||
expectedArgs.Add(AnchorStyles.Top); |
||||
|
||||
string code = "TestClass(System.Windows.Forms.AnchorStyles.Top)"; |
||||
CallExpression callExpression = PythonParserHelper.GetCallExpression(code); |
||||
List<object> args = deserializer.GetArguments(callExpression); |
||||
|
||||
Assert.AreEqual(expectedArgs, args); |
||||
} |
||||
|
||||
[Test] |
||||
public void BooleanParameter() |
||||
{ |
||||
List<object> expectedArgs = new List<object>(); |
||||
expectedArgs.Add(true); |
||||
|
||||
string code = "TestClass(True)"; |
||||
CallExpression callExpression = PythonParserHelper.GetCallExpression(code); |
||||
List<object> args = deserializer.GetArguments(callExpression); |
||||
|
||||
Assert.AreEqual(expectedArgs, args); |
||||
} |
||||
|
||||
[Test] |
||||
public void LocalVariableInstance() |
||||
{ |
||||
string s = "abc"; |
||||
CreatedInstance instance = new CreatedInstance(typeof(string), new object[0], "localVariable", false); |
||||
instance.Object = s; |
||||
componentCreator.CreatedInstances.Add(instance); |
||||
List<object> expectedArgs = new List<object>(); |
||||
expectedArgs.Add(s); |
||||
|
||||
string code = "TestClass(localVariable)"; |
||||
CallExpression callExpression = PythonParserHelper.GetCallExpression(code); |
||||
List<object> args = deserializer.GetArguments(callExpression); |
||||
|
||||
Assert.AreEqual(expectedArgs, args); |
||||
} |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue