Unit tests on a Data Store handling in Metro Apps RRS feed

  • Question

  • I am trying to make unit tests on my handling file class

    public async  void TestMethod1()
          ObjTest myObj= new ObjTest ("title 1", "description 1");
          await DataModel.SaveObj(myObj, EFolderName.Test);
          NUnit.Framework.Assert.AreEqual(DataModel.DoesFileExistAsync("title 1", EFolderName.Test), true);

    Exception occurs when it ties to get the Data Store Folder 

     public async static Task<bool> SaveObj(ObjTest objTest, EFolderName type)
                    //Exception occurs here!!!!!
                    StorageFolder storage = Windows.Storage.ApplicationData.Current.LocalFolder;
                 Catch (Exception e)

    It raises the System.InvalidOperationException "the process has no package identity"

    Do you know if it is possible to make unit tests on Data Store  operations in WinRT and HOW??

    • Edited by viv75 Thursday, September 19, 2013 8:38 AM
    Thursday, September 19, 2013 8:33 AM


  • Hi Viv,

    That is expected. The app doesn't have local folders until it's deployed and running in the app package context.

    I suspect that is beyond the capability of unit testing, but if you are using the Visual Studio testing frameworks you can try asking in those forums if one can control the context in which the unit tests run.


    • Marked as answer by Anne Jing Wednesday, September 25, 2013 1:34 AM
    Thursday, September 19, 2013 7:46 PM