devlooped / moq

The most popular and friendly mocking framework for .NET
Other
5.94k stars 802 forks source link

unable to mock in unittesting on windows app? #79

Closed Charlemagne65 closed 10 years ago

Charlemagne65 commented 10 years ago

Install-Package : Could not install package 'Moq 4.2.1312.1622'. You are trying to install this package into a project that targets '.NETCore,Version=v4.5.1', but the package does not contain any assembly references or content file s that are compatible with that framework. For more information, contact the package author. At line:1 char:1

I would like using moq in a Windows Store App. But this is the message I get from the NUGet PM.

What is going wrong?

Charlemagne65 commented 10 years ago

Sorry this was my command to the NUGet console:

PM> Install-Package Moq

Installing 'Moq 4.2.1312.1622'. Successfully installed 'Moq 4.2.1312.1622'. Adding 'Moq 4.2.1312.1622' to Generator. Uninstalling 'Moq 4.2.1312.1622'. Successfully uninstalled 'Moq 4.2.1312.1622'. Install failed. Rolling back...

kzu commented 10 years ago

Windows Store apps do not support dynamic code emitting (which is what Moq and all other dynamic proxy-based frameworks use), as noted in MSDN: http://msdn.microsoft.com/en-US/library/windows/apps/hh441595(v=vs.110).aspx

So Moq4 cannot support this platform.

Charlemagne65 commented 10 years ago

Ok,

what are my alternatives besides writing my mocking classes manually?

stakx commented 6 years ago

@Chakotay - this issue is super old, but just for the record, Moq 5 will likely support this scenario.