mocking the static methods and private members using asmock

601 Views Asked by At

1.Is there any way to access the private data members of a class in action script using asmock framework? I tried using syntax like

ContentPlayer[“getContentPlayer”]=mockContentPlayer;

Where in getContentPlayer is a private member and mockContentPlayer is alias am creating, but its not working well, I doubt whether I can do like this?

  1. Is there any way to mock the public static methods of actionscript using asmock?
2

There are 2 best solutions below

0
On

You can't access private fields from outside of class in AS3. Period.

0
On

asMock uses inheritance to intercept calls to the methods. As it's not possible to override a static or private method in the AVM, it's not possible for asMock to add support for it.

I'd recommend abstracting the static call with an interface and accepting an instance in the constructor.