Hello my dear developers!
How do you feel today?
These days I had to get started with UWP (which I’ve never used in my life).
No panic, it’s the old xaml c# way, bindings work, IOC works, etc.
Just for the sake of testing it I assembled a little project with Unit Test and MVVMLight library and Unity (IOC Container), but first of all it took a little bit of time to assemble it all (6 hours, searching for a web service, searching how everything was done on uwp, bootstraping, trying template stuff that I didn’t get to work, etc). I’m not saying it’s a lot of time for a test from 0 to having a decent data consuming application, but there was room for improvement.
The real tricky part came when I tried to unit test a UWP library, I just assumed everything would work as always, you know… Adding a test project and so one, but my surprise was that I wasn’t able to get a reference for my UWP library or UWP Application project, so I searched online and found this article Unit Test on UWP from Not only .net and was quiet help full.
So just for the clearness I would start the following way:
- Create an app project
- Create a UWP library project
- Create a Unit Test App
Since the Unit Test app is the trickier because and is not on test projects templates, here is an image of how its done
So the project structure is something like this
I’d run my first test just for the fun of it
Now comes the XUnit part (RMB on the unit test project an Manage Nuget Packages)
Now delete the test reference
and let’s tweak the project.json to update our refernces to uwp and xunit
Original after nuget
Now let’s run our first XUnit test
There you go if you want more info on XUnit go to the documentation on github
I hope this is as useful for you as it was for me an from now on I’ll try to improve my MVVM IOC project assembling time starting for this incredible template called t10, It’s great and even has its on MVA Course, take a look here it’s a dream come true.
Happy coding and remember…there is life beyond coding🙂