0

My C# code is using a class written in Java (IKVM). That Java class provides 2 methods that I am calling in my C# code:

  1. GetInstance() - It simply returns the instance of that Java class.
  2. GetSet() - returns a java.util.Set that I iterate over to do some processing.

We use NUnit and NMock and I am relatively new to mocking/stubbing, so I am quite confused on how to write unit test cases for this piece of C# code which will return a Java object etc.

Any help/pointers would be highly appreciated. Thanks.

Andy
  • 2,393
  • 4
  • 18
  • 20
  • I haven't used IKVM, but I strongly suspect it will be wrapping the java objects with .Net objects so mocking/testing is going to be largely the same as for any other code. You are likely to get a better response if you can include a minimal example of the code you want to to test, along with your attempt at creating a test for it and any errors that you encounter. – forsvarir Mar 17 '15 at 11:14
  • 1
    @forsvarir actually there's no wrapping whatsoever, the Java bytecode is recompiled to MSIL by ikvmc (**if** you use ikvmc), so you get regular .Net classes. They feel very Java-ish :) but you can mock them just like any other .Net code indeed. – Lucas Trzesniewski Mar 20 '15 at 21:54

0 Answers0