Rhino Mocks & Compact Framework - compact-framework

I've been experimenting with Rhino Mocks for unit testing my .Net Compact Framework application, and have hit a problem. I can get a basic unit test using Rhino Mocks built, but every time I run the test that has the Rhino Mocks code in it, the test fails because it can't find the Rhino Mocks assembly.
System.TypeLoadException: Could not load type 'Rhino.Mocks.MockRepository' from assembly 'Rhino.Mocks...
I've copied the rhino mocks dll to various places on the device (my app folder, and the SmartDeviceTest folder that gets created) but it still can't seem to find it.
Has anyone used rhino mocks with the compact framework and can point me in the right direction? Or failing that, can anyone suggest a mocking framework that does integrate and work with compact framework?
Thanks
Matt

My bet is that it can't find a dependency. IIRC, Rhino uses a lot of the CompilerServices and Reflection.Emit pieces which simply don't exist in the CF, so it's probably puking when trying to generate the mocks. I've not seen any mocking framework that works with the CF, and I've done quite a bit of looking (and trying to port).

I wrote a blog post on just this a few months ago:
http://elegantcode.com/2009/04/29/unit-testingmocking-on-net-cf/
Anyway, RhinoMocks, Moq, and TypeMock do not work on .netcf. Stubs from PEX (a Microsoft Research project) can work in theory, but is not there yet.
The key is to make stub classes instead of Mock classes (google search "Mocks are not Stubs")

Related

Quarkus #QuarkusTest vs #QuarkusIntegrationTest

Apologies if it has been answered before, but I can't seem to find a good answer.
What is the context of how #QuarkusTest runs versus QuarkusIntegrationTest?
So far, all I got is the integration test runs against a packaged form of the app (.jar, native compilation), whereas the plain #QuarkusTest doesn't? But this does not leave much explanation, and apologies if this comes from a lack of understanding in test runtimes.
To start a test instance of Quarkus (via #QuarkusTest), does it not compile and package into a jar? Makes sense to not I suppose, and just test against running compiled classes but I would rather get the real answer than assuming.
https://quarkus.io/guides/getting-started-testing#native-executable-testing
Besides the difference you mention, there's another crucial difference between #QuarkusTest and #QuarkusIntegrationTest. With #QuarkusTest, the test runs in the same process as the tested application, so you can inject the application's beans into the test instance etc., while with #QuarkusIntegrationTest, the tested application runs in an external process, so you can only interact with it over network.

How to do HotSwapping without using IDE?

I've used DCEVM hotswap technology in eclipse and IntelliJ IDE which was pretty cool feature. By using DCEVM in IDE what I can do is, I can change into the source code i.e add/remove/edit method, classes, properties at the runtime without doing restart the program.
Now my question is:
I want to apply the same features in my running application which is run without using any IDE. To be more specific the running applications source code(compiled code) can change on the fly. And for that bytecode how to deploy on DCEVM for runtime hotswapping?
What I've found is:
We can do hotSwapping without using IDE for that we can write own JNI code to directly hook into JVMTI and trigger a hotswap.
any idea/help would be much helpfull. thanks
Fortunately I found the solution.We can use the HotSwapper plugin to solve this kind of problem. The same question is asked in dcevm discussion forume:
https://groups.google.com/forum/#!topic/hotswapagent/Uk3cUdkHNYQ
Although the information from this link https://news.ycombinator.com/item?id=3198497 is very helpfull but it was asked four years ago, so that I was stuck in.
Now the DCEVM is being more smart It can support various plugin such as Hotswapper, AnonymousClassPatch, WatchResources, Hibernate, Spring, Jersey2, Jetty, Tomcat, ZK, Logback, JSF, Seam, ELResolver, OsgiEquinox and even we can write own plugin too which is more easy to develope.

Ninject and MonoDroid

Anyone had any luck getting Ninject to work on MonoDroid? i've tried the 2.0 and 4.0 mono builds from their website and also tried the .net versions.
With the Mono builds i'm getting a MissingMethodException in the instantiation of my StandardKernel
I am experimenting with Ninject on a combined WP7/Monotouch/Mono for Android project and Ninject works surprisingly good.
I used the latest sources, which contain a project file Ninject.WP7.csproj which seems to be outdated. It contains a lot of DefineConstants. I created new WP7/Monotouch/Mono for Android solutions with these constants and everything compiled and works!
Constants used:
SILVERLIGHT,SILVERLIGHT_40,NO_LCG,NO_ASSEMBLY_SCANNING,NO_WEB,NO_PARTIAL_TRUST,NO_SKIP_VISIBILITY,NO_EXCEPTION_SERIALIZATION,NO_DEBUG_SYMBOLS
not sure if they are all needed, but the SILVERLIGHT one is important because Monotouch/Mono for Android implement a large part of the Silverlight api.
Of course you cannot create Android Activities with Ninject. I use it mainly for constructor injection, to create .Net objects like a ViewManager, view models using a repository, etc., the usual things you do with dependency injection.
I haven't tried to get Ninject working, but I'd be very surprised if it just worked out of the box. If there's a Silverlight build of Ninject you may have more luck with that, but there are no guarantees. The "best" way to get support for it in Mono for Android would be to build the code against the Mono for Android profile as a class library.
That said, there are other options out there for doing service location in your apps. I have a blog post up here that talks about using TinyIoC and Funq for service location.

Using cucumber to test an API not written in rails

I'm writing an API using a non-rails framework. I normally use Cucumber for BDD and testing of API's when I'm writing them in RAILS.
Is there a strong reason not to use Cucumber when I'm testing an API written on top of node.js (or any other framework, really)?
Strong technical reasons to not do this might include:
Dependency of Cucumber on Rails
The existence of a better framework for node.js
Some other technical reason I don't know about.
First of all, Cucumber doesn't depend on Rails.
I have been trying out some different javascript testing frameworks to try to work out what I want to use. So far I like mocha with expect.js for unit testing but I haven't found anything for integration testing a node app that I'm happy with. It's possible to do with mocha and supertest, and I've also tried cucumber.js which is getting there but it's not as mature as the Ruby version - so that's what I intend to use.
I can't think of a good reason not to do this, apart from it may be harder to do things like set up fixtures - but that may well be a good thing as it would force your tests to deal only with the public interface of your API - as it was intended to be used.
As said cucumber has nothing to do with rails.
You could perfectly use it to test API's written in any languages.
In case you want to use node.js full stack cucumber.js is a good option.

Moq (or possibly another framework) on Mono / MonoTouch

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.
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!)