Exemple #1
0
 def test_GetEnumerator(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     x = ArrayList()
     enum = x.GetEnumerator()
     assert enum.MoveNext() is False
Exemple #2
0
 def test_getitem(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     obj.Add(42)
     assert obj[0] == 42
Exemple #3
0
 def test_unboundmethod(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     ArrayList.Add(obj, 42)
     assert obj.get_Item(0) == 42
Exemple #4
0
	def Scalar(self, command, *values):
		from System.Collections import ArrayList
		list = ArrayList()
		for value in values:
			list.Add(value)
		table = self.base.Query(command, list.ToArray())
		return table.Rows[0][0]
Exemple #5
0
 def test_float_conversion(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     obj.Add(42.0)
     item = obj.get_Item(0)
     assert isinstance(item, float)
Exemple #6
0
 def test_string_wrapping(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     x = ArrayList()
     x.Add("bar")
     s = x[0]
     assert s == "bar"
Exemple #7
0
 def test_ArrayList(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     obj.Add(42)
     obj.Add(43)
     total = obj.get_Item(0) + obj.get_Item(1)
     assert total == 42 + 43
Exemple #8
0
 def test_overload(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     for i in range(10):
         obj.Add(i)
     assert obj.IndexOf(7) == 7
     assert obj.IndexOf(7, 0, 5) == -1
Exemple #9
0
 def test_property(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     obj.Add(42)
     assert obj.Count == 1
     obj.Capacity = 10
     assert obj.Capacity == 10
Exemple #10
0
	def NonQuery(self, command, *values):
		from System.Collections import ArrayList
		list = ArrayList()
		for value in values:
			list.Add(value)
		if list.Count == 0:
			return self.base.NonQuery(command)
		elif list.Count == 1:
			return self.base.NonQuery(command, list[0])
		else:
			return self.base.NonQuery(command, list.ToArray())
Exemple #11
0
 def test_None_as_null(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     Hashtable = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'Hashtable')
     x = ArrayList()
     x.Add(None)
     assert x[0] is None
     y = Hashtable()
     assert y["foo"] is None
Exemple #12
0
    def test_pass_opaque_arguments(self):
        import clr
        ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                       'ArrayList')

        class Foo:
            pass

        obj = Foo()
        x = ArrayList()
        x.Add(obj)
        obj2 = x[0]
        assert obj is obj2
Exemple #13
0
 def test_bool_conversion(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     obj.Add(True)
     obj.Add(False)
     t = obj.get_Item(0)
     f = obj.get_Item(1)
     assert t and isinstance(t, bool)
     assert not f and isinstance(f, bool)
     obj.Add(42)
     assert obj.Contains(42)
Exemple #14
0
 def test_iteration_arrayList(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     x = ArrayList()
     x.Add(1)
     x.Add(2)
     x.Add(3)
     x.Add(4)
     sum = 0
     for i in x:
         sum += i
     assert sum == 1 + 2 + 3 + 4
Exemple #15
0
	def Query(self, command, *values):
		from System.Collections import ArrayList
		list = ArrayList()
		for value in values:
			list.Add(value)
		if list.Count == 0:
			for dataRow in self.base.Query(command).Rows:
				yield Row(dataRow)
		elif list.Count == 1:
			for dataRow in self.base.Query(command, list[0]).Rows:
				yield Row(dataRow)
		else:
			for dataRow in self.base.Query(command, list.ToArray()).Rows:
				yield Row(dataRow)
Exemple #16
0
 def test_ArrayList_error(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList()
     raises(StandardError, obj.get_Item, 0)
Exemple #17
0
 def test_constructor_args(self):
     import clr
     ArrayList = clr.load_cli_class(self.mscorlib, 'System.Collections',
                                    'ArrayList')
     obj = ArrayList(42)
     assert obj.Capacity == 42