Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4d60c6

Browse files
committed
Add tests for collection & task/action from function
change enumerable method to non-static add tuple test for ienumerable
1 parent 21528ee commit b4d60c6

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/testing/methodtest.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,29 @@ public static int[] TestOverloadedParams(int v, int[] args)
117117
return args;
118118
}
119119

120-
public static int TestIEnumerable(System.Collections.Generic.IEnumerable<object> arg)
120+
public static int TestIList(System.Collections.Generic.IList<object> arg)
121+
{
122+
return 1;
123+
}
124+
125+
public static int TestICollection(System.Collections.Generic.ICollection<object> arg)
126+
{
127+
return 1;
128+
}
129+
130+
public int TestAction(System.Action action)
131+
{
132+
action();
133+
return 1;
134+
}
135+
136+
public int TestTask(System.Threading.Tasks.Task<int> task)
137+
{
138+
task.RunSynchronously();
139+
return task.Result;
140+
}
141+
142+
public int TestIEnumerable(System.Collections.Generic.IEnumerable<object> arg)
121143
{
122144
return 1;
123145
}

src/tests/test_method.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,33 @@ def test_null_array_conversion():
204204
r = ob.TestNullArrayConversion(None)
205205
assert r is None
206206

207+
def test_action():
208+
"""Test python lambda as an action"""
209+
ob = MethodTest()
210+
def func():
211+
return
212+
r = ob.TestAction(func)
213+
assert r == 1
214+
215+
def test_task():
216+
"""Test python lambda as an action"""
217+
ob = MethodTest()
218+
def func():
219+
return 1
220+
r = ob.TestTask(func)
221+
assert r == 1
222+
207223
def test_ienumerable_args():
208224
"""Test conversion of python lists and tuples to IEnumerable<object>"""
209225
ob = MethodTest()
210226
x = ob.TestIEnumerable([1,2,3])
211227
y = ob.TestIEnumerable((1,2,3))
212228

229+
def test_icollection_args():
230+
"""Test conversion of python lists and tuples to ICollection<object>"""
231+
ob = MethodTest()
232+
x = ob.TestICollection([1,2,3])
233+
213234
def test_string_params_args():
214235
"""Test use of string params."""
215236
result = MethodTest.TestStringParamsArg('one', 'two', 'three')

0 commit comments

Comments
 (0)