Lakshmi Kantha
Lakshmi Kantha

Reputation: 11

mocking the static methods and private members using asmock

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?

Upvotes: 1

Views: 592

Answers (2)

Richard Szalay
Richard Szalay

Reputation: 84754

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.

Upvotes: 1

mizi_sk
mizi_sk

Reputation: 1007

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

Upvotes: 0

Related Questions