Commit 106b34ce authored by Vinicius Jarina's avatar Vinicius Jarina
Browse files

Added test to ctor overload.

parent 24280821
...@@ -22,9 +22,11 @@ namespace ConsoleTest ...@@ -22,9 +22,11 @@ namespace ConsoleTest
{ {
using (var l = new Lua ()) { using (var l = new Lua ()) {
l.LoadCLRPackage (); l.LoadCLRPackage ();
l.DoString (" import ('ConsoleTest') "); l.DoString (" import ('ConsoleTest', 'NLuaTest.Mock') ");
l.DoString (@" l.DoString (@"
Program.Method (1) e1 = Entity()
e2 = Entity ('Another world')
e3 = Entity (10)
"); ");
} }
} }
......
Subproject commit 2f0dfdcc50acca3e88afa6ef5cc5ad97f142e57a Subproject commit 7dbc7e4f95e9a7a60d59ef500e7767284aede57c
...@@ -18,11 +18,28 @@ namespace NLuaTest.Mock ...@@ -18,11 +18,28 @@ namespace NLuaTest.Mock
} }
} }
public string Property {
get;
set;
}
// default ctor
public Entity () public Entity ()
{ {
Property = "Default";
}
// string ctor
public Entity (string param)
{
Property = "String";
} }
public Entity (int param)
{
Property = "Int";
}
public void Click () public void Click ()
{ {
OnEntityClicked (new EventArgs ()); OnEntityClicked (new EventArgs ());
......
...@@ -2472,6 +2472,29 @@ namespace NLuaTest ...@@ -2472,6 +2472,29 @@ namespace NLuaTest
} }
} }
[Test]
public void TestConstructorOverload ()
{
using (var l = new Lua ()) {
l.LoadCLRPackage ();
l.DoString (" import ('NLuaTest','NLuaTest.Mock') ");
l.DoString (@"
e1 = Entity()
e2 = Entity ('str_param')
e3 = Entity (10)
p1 = e1.Property
p2 = e2.Property
p3 = e3.Property
");
string p1 = l.GetString ("p1");
string p2 = l.GetString ("p2");
string p3 = l.GetString ("p3");
Assert.AreEqual ("Default", p1, "#1");
Assert.AreEqual ("String", p2, "#1");
Assert.AreEqual ("Int", p3, "#1");
}
}
static Lua m_lua; static Lua m_lua;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment