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?
- Is there an开发者_运维技巧y way to mock the public static methods of actionscript using asmock?
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.
You can't access private fields from outside of class in AS3. Period.
精彩评论