Is it possible to mock the Assembly class?
If so, using what framework, and how?
If not, how would do go about writing tests for code that uses Assembly?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
TypeMock is very powerful. I guess it can do it. For the other mock frameworks like Moq or Rhino, you will need to use another strategy.
Strategy for Rhino or Moq:
Per example: You are using the Asssembly class to get the assembly full name.
The Assembly class derived from the interface
_Assembly. So, instead of using Assembly directly, you can inject the interface. Then, it is easy to mock the interface for your test.The modified class:
In your test, you mock
_Assembly: