Moq (or possibly another framework) on Mono / MonoTouch

天大地大妈咪最大 提交于 2019-12-04 12:01:46

问题


I've just started some MonoTouch development and I've tried, and failed, to get Moq working for my unit tests. The binary version fails because it's looking for System v2.0, which I assume is down to its Castle requirements, and building it from source crashes the compiler!

My question is has anyone gotten Moq to work on Mono (the touch part should be irrelevant, I'm not deploying it to the phone!), or had any joy with any of the other mocking frameworks? Failing that I'm back to rolling my own, which is a bit of a pain.


回答1:


I'm using Moq right now with Monodevelop to test the non-Monotouch parts of a Monotouch app, and I haven't had any trouble. For the target runtime, my test project and the code under test both use Mono / .NET 3.5, and for references, it's got:

  • System, Version=2.0.0
  • nunit.core, Version=2.4.8
  • nunit.framework, Version=2.4.8
  • [code under test]
  • System.Core, Version=3.5.0
  • Moq.dll

System, nunit.core and nunit.framework are all as provided by Monodevelop.

The Moq I'm using is Moq.4.0.10827/NET35/Moq.dll.

(I haven't had any luck NUnit-testing the Monotouch parts -- I assume because when the tests are running, there's no phone or simulator, so the native code Monotouch is wrapping can't run. I've had to separate out the non-iOS-specific parts of the app and set up two separate solutions, one for real builds and one for unit testing the parts that can be unit tested. If you've gotten farther than that, let me know!)



来源:https://stackoverflow.com/questions/2401000/moq-or-possibly-another-framework-on-mono-monotouch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!