Open weltraumpirat opened 12 years ago
In the first case with just [Mock]
Mockolate will inject null
for all
constructor parameters as the describeType()
reflection information does
not indicate which parameters are required or optional. I will be improving
this situation shortly by using the as3-commons-bytecode library for
reflection and proxy generation.
In the second case with [Mock(args="constructorArgs")]
, it looks like you
are doing the correct thing. I will need to investigate further.
To discuss this issue at a higher level my suggestion is to avoid mocking the runtime classes, such as Bitmap. Instead introduce an interface for the manipulations you intend to perform, eg: IPixelTranformable which mirrors the API of the Bitmap methods you want to use, then type to that interface instead of the concrete Bitmap class and create a small extention class of Bitmap which implements the IPixelTransformable.
On Sat, Jun 2, 2012 at 12:58 AM, weltraumpirat < reply@reply.github.com
wrote:
I have several subclasses of Bitmap I need to use for a complex pixel transformation, and I've run into the following problem:
- If I use the
[Mock]
annotation only, the test crashes and complains that thepixelSnapping
argument must not benull
. The funny thing is: all Bitmap constructor arguments have a default value, and so do the constructor args of my derived class.- If I use
[Mock(args="constructorArgs")], I do not get any errors, and I verified that the
constructorArgsfunction (which returns
[null, "auto", true]) is called correctly. But instead of a mock object,
null` is assigned to the variable.- I get the same
null
result if I trynice(Bitmap, "", [null, "auto", true]);
Reply to this email directly or view it on GitHub: https://github.com/drewbourne/mockolate/issues/62
I have several subclasses of Bitmap I need to use for a complex pixel transformation, and I've run into the following problem:
[Mock]
annotation only, the test crashes and complains that thepixelSnapping
argument must not benull
. The funny thing is: all Bitmap constructor arguments have a default value, and so do the constructor args of my derived class.[Mock(args="constructorArgs")]
, I do not get any errors, and I verified that theconstructorArgs
function (which returns[null, "auto", true]
) is called correctly. But instead of a mock object,null
is assigned to the variable.null
result if I trynice(Bitmap, "", [null, "auto", true]);