How to write Visual Studio unit tests for private C++model layer in MVVM Windows Store app?

Viewed 371

I am in the process of writing a fairly complex Windows Store app. To keep the code maintainable, I would like to make good use of unit tests. So far my solutions consists of the following:

  1. A C#/XAML project for the app itself and the view layer
  2. A C++ Windows Store project wherein the ViewModel layer consists of managed WinRT ref classes while the model layer is straight C++ and entirely hidden from the view layer.
  3. A C# Windows Store unit test project to test the ViewModel layer.
  4. A C++ project to do some DirectX rendering (part of the view layer and not really relevant for this post)

Testing the C++ WinRT ViewModel classes with the C# project is working fine. It doesn't matter that a different language because everything is public and using the WinRT interface.

However, for testing the model layer classes I am not sure what to do. I would like my test cases to be in a separate project, but I am not sure if this even possible. I want to keep everything here standard C++ for portability reasons. Furthermore, I am trying to keep everything hidden so that I can adhere to strict MVVM design.

How should I write Visual Studio unit tests (like those which are in my ViewModel "Unit Test Library (Windows Store apps)") for my standard C++ model layer?


One option I'm looking at right now is to create a "Native Unit Test Project" and use the folder for my model layer project as an include directory for that. Seems like I'm almost there, but I'm getting "error LNK2019: unresolved external symbol". How can I build the CPP files for the objects that include with the test project.

1 Answers
Related