What can I say? Unit testing Windows 8 applications is a painful experience. It’s hard to apply mocking and some stuff is not easy to discover.
Last week I created a Windows 8 unit test that required a specific file to be available on the file system. So I added the file to my test project, changed the Build action to content and set Copy to output directory to Copy always.
But now the hard part what code should I use to read out the file from the file system?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var folder = Package.Current.InstalledLocation; | |
var stream= folder.OpenStreamForReadAsync("Filename.txt") |
That's it. Once you found it, it's actually not so difficult.