intellisense fails for file added to NUnit[Lite] project in Xamarin/Mono - intellisense

I'm trying out Xamarin (on Mac OS X) to do some cross-platform (Mac, iOS, Android) development in Mono. I've created a "Point" class inside a "Filament" namespace, and now I'm trying to add unit tests.
There appear to be two approaches to unit testing in the Mono world: NUnit and NUnitLite. I've tried both (in the latter case, following this tutorial), with the same result, which is this:
In my unit test project, I add a link to the Point.cs file (by right-clicking the project, using 'Add...', selecting the file, and then choosing the "Add as Link" option). In my unit test file (PointTest.cs), I add "using Filament;" to the top of the file. But despite the fact that I can now use the Point class, and it successfully compiles, Intellisense seems completely oblivious to it -- every time I start to type "Point" it extends this to "PointTest", and when I doggedly change it back to Point, it draws it in red like an error.
In fact, the same trouble happened on my "using" line; I typed "using Filament" and it changed this to "using FilamentTestsiOS" (the namespace of my unit test project).
This is driving me nuts... but as a complete noob to Mono, Xamarin, NUnit, and NUnitLite, I'm sure I'm doing something stupid.
What's the correct way to set up a C#/Mono unit test, so that both intellisense and the compiler will recognize the classes for which I'm writing tests?

Related

Passing Non-Command Line parameters to TornadoFX App in Kotlin

I'm fairly new to developing GUIs, and especially new to JavaFX/TornadoFX, and I'm not really sure how to do what I'm trying to do.
The gist is I'm trying to make a small IDE, and I want to be able to provide the TornadoFX App a particular Interpreter for the IDE:
class IDE(i: Interpreter) : App(IDEView::class)
But this doesn't work, since the configuration to run the App in IntelliJ just points to the IDE class, and doesn't specify what the parameter is.
Why I try to run it, basically it complains that the IDE class did not get the arguments it needs, but there is no way (in the configuration to run the App in IntelliJ) to specify parameters. If I create my own main and manually use:
launch<IDE>()
I can pass arguments, but the only thing it accepts are command line args (like an Array of Strings).
I'm planning on trying to follow the MVC pattern as closely as possible, and the Interpreter (interface) here is basically the Model behind everything. This is a project I'm working on with a friend, so he's working on the Model, and I'm going to be making the Controller and View. If there's no "clean" way to provide a custom Model, then I can just hard code it straight into the App, but I'd prefer to avoid that (and learn how to do it properly).

Objective C Unit Test Setup

I have been learning Objective C and Xcode for a few months now, and I am trying to setup some unit tests.
All of my projects are OS X "Command Line Tool" Applications. I use main.m to write code to test the methods and classes I've developed. That works fine. I'm trying to migrate to test targets and unit testing.
I am using "Testing with Xcode" as a guide, but I'm having some issues:
When I create a "Test Target", the "Target To Be Tested" field
defaults to "None", and can't be changed. Is that okay?
I am able to run the default tests. They pass. But when I create a new test that references a class method that I've written, I get a link error for each class method instance. (not a compile error)
My "ExampleTest.m" test target has an '#import "MyApp.h"', Is there any other setup I need to do?
The "Testing with Xcode" doc shows a setup test method that invokes the ViewController for the app being tested. I don't have a ViewController for my command line app, and I'm only trying to create unit tests, so I'm not sure how to modify that example...
Bonus Question: I have several classes that I add methods to, and want to reuse. How do I keep the unit tests with the source code for reuse? The Test Navigator hierarchy seems to be app-centric. How to others keep their classes and unit tests for those classes in sync?
OS X "Command Line Tool" applications do not include testing. Need to select "Cocoa Application" to include testing.

Changing application setting in Unit test

I have created a unit test in a separate project. I am trying to change a filepath I have as a setting in the main project. I access the path as My.Settings.FooBarPath. I can't figure out how to change it in my unit test. How do I access the settings in my main project from the unit test project and how do I change the values?
I have read this post: Modifying application settings in unit tests
The second answer seemed to be the most useful but I couldn't quite seem to get it to work for my unit tests.
One way is to modify the settings.xml file manually. It's a bit convoluted, but this tutorial might help for saving and loading text files into your app (of course you'd do it without a UI) - https://www.youtube.com/watch?v=O3nSXaD2J9Q
Another option is to start up your other program with Shell() and have a command line argument for the setting to change and what to change it to.
The question asked was for VB.Net while the answer given in Modifying application settings in unit tests is for C#. As I had the same question for VB.Net I thought I'd give a VB.Net version of the answer here. Based on the C# answer I got this to work in my project (using Visual Studio 2013) with the following:
The test project should be correctly set up as a unit test for the application under test ("Create and run unit tests" should help in setting it up correctly)
using the fully qualified namespace of the application under test myprojects_namespace.My.settings
will give you full (intellisense powered) access to the user settings of the application under test.
After that you can read / write to the user settings as you would normally do.
e.g.
myprojects_namespace.My.settings.someProperty = "somevalue"
Assert.AreEqual("somevalue", myprojects_namespace.My.settings.someProperty)
P.S.: I didn't need to add anything in my AssemblyInfo.vb file. There is no reference to System.Runtime.CompilerServices.InternalsVisibleTo as this seems to already have been handled by setting up the unit test project correctly for the application under test.

Baffling Xcode Plugin build trouble

I'm trying to build an Xcode plugin using this template. As a matter of fact the template works perfectly, but the problem is that something strange happened and it stopped loading the plugin. After 3 hours of trial & error, I pinpointed the problem but I cannot get my head around this...
I have a class called MHStatement and when I build without including this class, the plugin works fine and appears in the Xcode menu bar as expected.
However, when I include the MHStatement.h and MHStatement.m files in the project and then build, the plugin fails to load.
Now the fun part is that if I rename MHStatement to Statement and build it still doesn't work.
But if I make a new interface & implementation Statement overwriting the above Statement files it works again.
Moreover, creating new classes named _MHStatement, __MHStatement, MXStatement, MBStatment, MHFatment also make it fail, but XXStatement, DDStatement, XHStatement is OK.
But when I create a class XXStatement, and refactor->rename it to MHStatement and build,
the plugin loads normally.
This is obviously some weird runtime or linking error, but I don't know how to even start looking for what exactly is happening.
I am not sure if this is reproducible by any means, so I would just kindly ask for any advice that might come to your minds.
Cheers!
EDIT
I tried creating a new class MHStatement and adding it to BBUncustify plugin. Building the plugin like this also prevents it to load, but now I'm getting this warning
objc[6278]: Class MHStatement is implemented in both /Users/marko/Library/Application Support/Developer/Shared/Xcode/Plug-ins/UncrustifyPlugin.xcplugin/Contents/MacOS/UncrustifyPlugin and /Users/marko/Library/Application Support/Developer/Shared/Xcode/Plug-ins/PluginTest3.xcplugin/Contents/MacOS/PluginTest3. One of the two will be used. Which one is undefined.
with tail -f /var/log/system.log
I ended up creating a new project from scratch, and now have 3 separate targets, a framework for the code base that actually does all the work, test cases for the framework, and a simple one class plugin target, which works fine with that setup.
I hope some day someone will be able to answer what exactly was happening, and Apple will become kinder to Xcode modding community.

Replicate class with main method as in Java IDE within Objective-C and Xcode 4

I have a simple question. Coming from a java background and having worked extensively with eclipse, netbeans or any other java IDE, is quite nice to have the possibility to add a main method to a class and execute it within the IDE, with just a click, and see the output.
I was looking for the same possibility within xcode4/objective-c but I couldn't find a way. From time to time, I like testing small piece of software, without compiling and running the whole project.
As I am still "thinking" in Java, could you suggest the proper way to achieve this with xcode4 from an "objective-c developer point of view" ?
thanks
There's not really a lightweight way to do this, but you have two options that I can think of depending on whether you want to keep the harness code you've written.
If you do, then you'd need to make a new target in your project for each class you drive with a harness, and have that target build just the class you are driving and a simple file with just the main code to drive that class.
If you don't, then you could make a target with a main, and each time you want to drive a different class, change which files are built, change the code in main, and rebuild.
This is assuming that you want to avoid both running and compiling the rest of your code. If you don't mind compiling everything, you could have one test-harness target that builds all of your classes, and either change main on the fly, or use #ifdefs or a runtime argument to decide which helper code to run.