Live Unit Testing with embedded ressources

Refresh

February 2019

Views

6 time

0

I have a test using a embedded ressource to check. If i'm executing the test manually, everything works fine. I print all available ressources on startup.

Manually executed:

Available Ressources:
MyCompany.MyFile.json

If the same test is excecuted by the live unit testing, an error appears and the output is:

Available Ressources:
<DynamicAnalysisData>

Anybody an idea how to fix this, I'd love to make live unit testing with embedded ressources.

Method to get the ressource

{
    var assembly = Assembly.GetExecutingAssembly();

    string result;
    using (var stream = assembly.GetManifestResourceStream(resourceName)) 
    //at live unit-testing, a null reference exception appears while getting the stream
    using (var reader = new StreamReader(stream))
    {
        result = reader.ReadToEnd();
    }
    return result;
}

0 answers