def test_types(self): import clr from Merlin.Testing.FieldTest import Class, GenericClass, GenericStruct, Struct from Merlin.Testing.TypeSample import SimpleClass, SimpleStruct types = [ Struct, GenericStruct[int], GenericStruct[SimpleClass], Class, GenericClass[SimpleStruct], GenericClass[SimpleClass], ] o1 = clr.StrongBox[Struct](Struct()) o2 = clr.StrongBox[GenericStruct[int]](GenericStruct[int]()) o3 = clr.StrongBox[GenericStruct[SimpleClass]]( GenericStruct[SimpleClass]()) o4 = Class() o5 = GenericClass[SimpleStruct]() o6 = GenericClass[SimpleClass]() o7 = clr.StrongBox[Class](o4) o8 = clr.StrongBox[GenericClass[SimpleStruct]](o5) o9 = clr.StrongBox[GenericClass[SimpleClass]](o6) scenarios = [ (o1, True, types[0]), (o2, True, types[1]), (o3, True, types[2]), (o4, False, types[3]), (o5, False, types[4]), (o6, False, types[5]), (o7, True, types[3]), (o8, True, types[4]), (o9, True, types[5]), ] for o, vf, t in scenarios: self._test_get_by_instance(o) self._test_get_by_type(o, vf, t) self._test_get_by_descriptor(o, vf, t) self._test_set_by_instance(o, vf, t) self._test_set_by_type(o, vf, t) self._test_set_by_descriptor(o, vf, t) self._test_delete_by_type(t) self._test_delete_by_instance(t) self._test_delete_by_descriptor(t)
def test_types(self): import clr from Merlin.Testing.FieldTest import Class, GenericClass, GenericStruct, Struct from Merlin.Testing.TypeSample import SimpleClass, SimpleStruct types = [ Struct, GenericStruct[int], GenericStruct[SimpleClass], Class, GenericClass[SimpleStruct], GenericClass[SimpleClass], ] o1 = clr.StrongBox[Struct](Struct()) o2 = clr.StrongBox[GenericStruct[int]](GenericStruct[int]()) o3 = clr.StrongBox[GenericStruct[SimpleClass]](GenericStruct[SimpleClass]()) o4 = Class() o5 = GenericClass[SimpleStruct]() o6 = GenericClass[SimpleClass]() o7 = clr.StrongBox[Class](o4) o8 = clr.StrongBox[GenericClass[SimpleStruct]](o5) o9 = clr.StrongBox[GenericClass[SimpleClass]](o6) scenarios = [ (o1, True, types[0]), (o2, True, types[1]), (o3, True, types[2]), (o4, False, types[3]), (o5, False, types[4]), (o6, False, types[5]), (o7, True, types[3]), (o8, True, types[4]), (o9, True, types[5]), ] for i in range(len(scenarios)): exec("def test_%s_get_by_instance(): self._test_get_by_instance(scenarios[%s][0])" % (i, i)) exec("def test_%s_get_by_type(): self._test_get_by_type(scenarios[%s][0], scenarios[%s][1], scenarios[%s][2])" % (i, i, i, i)) exec("def test_%s_get_by_descriptor(): self._test_get_by_descriptor(scenarios[%s][0], scenarios[%s][1], scenarios[%s][2])" % (i, i, i, i)) exec("def test_%s_set_by_instance(): self._test_set_by_instance(scenarios[%s][0], scenarios[%s][1], scenarios[%s][2])" % (i, i, i, i)) exec("def test_%s_set_by_type(): self._test_set_by_type(scenarios[%s][0], scenarios[%s][1], scenarios[%s][2])" % (i, i, i, i)) exec("def test_%s_set_by_descriptor(): self._test_set_by_descriptor(scenarios[%s][0], scenarios[%s][1], scenarios[%s][2])" % (i, i, i, i)) exec("def test_%s_delete_by_type(): self._test_delete_by_type(scenarios[%s][2])" % (i, i)) exec("def test_%s_delete_by_instance(): self._test_delete_by_instance(scenarios[%s][2])" % (i, i)) exec("def test_%s_delete_by_descriptor(): self._test_delete_by_descriptor(scenarios[%s][2])" % (i, i))