W
waylonflinn
I'm looking for a way to invoke methods with an arbitrary number of
parameters of arbitrary type from within a single method, when those
parameters are known at the time of invocation of the containing
method. I don't see a reason why this shouldn't work. I also can't
find the language feature which implements it. More details below.
As part of the creation of a set of classes for doing unit testing I
want to create a generic 'RunTestMethod' method. This method will
encapsulate my reporting and data collection (whether a given test
passed or failed, how many tests have passed or failed so far). In
order to be useful it also needs to be capable of calling a method
with an arbitrary number of parameters (whose values are known when
the 'RunTestMethod' method is called). This is to preserve the
generality of the testing framework.
My first thought was to use delegates. This allows me to pass a
variety of methods to another method and invoke them therein. However,
I have yet to find a way of allowing a delegate to have arguments
whose number and type differ from the method to be invoked, even when
the arguments are known at the point of instantiation.
Can any of you think of a way of implementing this that doesn't
sacrifice generality?
parameters of arbitrary type from within a single method, when those
parameters are known at the time of invocation of the containing
method. I don't see a reason why this shouldn't work. I also can't
find the language feature which implements it. More details below.
As part of the creation of a set of classes for doing unit testing I
want to create a generic 'RunTestMethod' method. This method will
encapsulate my reporting and data collection (whether a given test
passed or failed, how many tests have passed or failed so far). In
order to be useful it also needs to be capable of calling a method
with an arbitrary number of parameters (whose values are known when
the 'RunTestMethod' method is called). This is to preserve the
generality of the testing framework.
My first thought was to use delegates. This allows me to pass a
variety of methods to another method and invoke them therein. However,
I have yet to find a way of allowing a delegate to have arguments
whose number and type differ from the method to be invoked, even when
the arguments are known at the point of instantiation.
Can any of you think of a way of implementing this that doesn't
sacrifice generality?