You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the pixelSnapping argument must not be null. 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 constructorArgs function (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 try nice(Bitmap, "", [null, "auto", true]);
The text was updated successfully, but these errors were encountered:
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.
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 the pixelSnapping argument must not be null. 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 theconstructorArgsfunction (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 try nice(Bitmap, "", [null, "auto", true]);
Reply to this email directly or view it on GitHub: #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]);
The text was updated successfully, but these errors were encountered: