This project is read-only.

xUnit instead of nUnit

May 24, 2015 at 2:34 PM
I updated the project to the latest revision and saw, that there is xUnit code?

Now my question is why? I'm open to it, since it seems to have some thought behind it's design, but I'd like to hear the other team members arguments.
May 24, 2015 at 2:59 PM
(Sorry if this post shows up twice in your e-mail, the first one didn't seem to go through)

xUnit is from the same folks behind nUnit. It offers a more modern approach to unit testing. The flip side of that coin is that it only supports .NET 4.5 or newer, but that's not an issue for this project.
May 26, 2015 at 8:46 PM
While we're on the topic of testing: do you know of any alternative to Moq that is supported by PCL libraries? The problem seems to be that all mocking frameworks use reflection, and that the Reflection namespace is heavily crippled in portable libraries compared to the full framework.

I'm now trying out EasyMoq, which doesn't use the same reflection features
May 27, 2015 at 5:26 PM
Why are we writing the unit test in PCL anyway? As long as we write the actual code in PCL we can write the tests in normal class libraries. I don'T think somebody is coding this on a machine with restricted .NET access.

So code in PCL, Tests and Mock in standard .NET
May 27, 2015 at 9:32 PM
It just made sense to me that the code should be tested with the same framework subset.

If the tests pass in PCL, then you can be sure that the code works on all platforms
If the tests pass using the full framework, then the only guarantee that you have is that the code works on desktop environments.
May 28, 2015 at 3:05 PM
Test should not validate the code, but rather the result.

We know that the code will run on all platforms, since the compiler can compile the code, this makes the code syntactically correct and thus runnable. However we don't know if this code will produce the correct results. For that we have UnitTests. Mocking frameworks on the other hand help us to decouple the code from uncertain sources, like a web api.
May 29, 2015 at 12:08 PM
What I meant is that portable class libraries have a limited base class library. There are things that you can do with the full framework that you can't do with a portable library. I write my tests using only the portable subset of the framework to ensure myself that my code does not require framework features that are not available on all platforms.
May 29, 2015 at 6:49 PM
I write my tests using only the portable subset of the framework to ensure myself that my code does not require framework features that are not available on all platforms.
Ensuring that is not the scope of UnitTests! You don't want to test that the code requires references that are not available, you have the compiler for that. That's also why you should use interfaces over concrete classes.
Example: You don't want to test if the items repository is usable with every possible code via UnitTests, you'll want to test if the implementation (that is syntactically correct by compiling) returns the correct results.

  • Use the compiler to check if the code runs on the machine
  • Use unit tests to verify that you get the correct result and no RuntimeErrors
  • Use a Mocking Framework to make yourself independent from uncertain sources (i.e. web apis and the like)
May 29, 2015 at 7:30 PM
That's all fine, until you start using reflection.
May 30, 2015 at 5:53 PM
Eric Lippert had an AMA some days ago. I hadn't had the chance to talk to him then, but I asked the question on his blog. Let's see if he answers it.
May 30, 2015 at 7:12 PM
Edited May 30, 2015 at 7:13 PM
Another thing to think about: xunit didn't have support for PCL libraries until xunit 2.0. There has to be a reason why the authors put hard work into making that happen.
May 30, 2015 at 9:08 PM
Edited May 30, 2015 at 9:11 PM
There's one feature that I really miss for testing data contract converters that depend on other converters: mocking the other converter to make sure that its Convert() method get called by the converter under test. Ideas? Suggestions?