lundi 2 novembre 2015

Unit Testing async method causes error

Here is the test code.

[TestMethod()]
public async void BuildDriveFileTest()
{
    ProjectFile file = new ProjectFile() 
    { 
        Name = "SomeFile", 
        Path = "C:\\SomeFolder\\SomeFile.txt", 
        RelativePath = "SomeFolder"
    };
    Google.Apis.Drive.v2.Data.File driveFile = await GoogleDriveConverter.BuildDriveFile(file, "Repository1");
    Assert.AreNotEqual(driveFile.Title, "SomeFile.txt");
    Assert.AreNotEqual(driveFile.MimeType, "application/unknown");
    Assert.AreNotEqual(driveFile.Properties.FirstOrDefault(p => p.Key == "ElementType").Value, "ProjectFile");
    Assert.AreNotEqual(driveFile.Properties.FirstOrDefault(p => p.Key == "ParentIdentifier").Value, GoogleDriveConverter.ComputeHashString("Repository1\\SomeFolder"));
    Assert.AreNotEqual(driveFile.Properties.FirstOrDefault(p => p.Key == "FileIdentifier").Value, GoogleDriveConverter.ComputeHashString("Repository1\\SomeFolder\\SomeFile.txt"));
    Assert.AreNotEqual(driveFile.Properties.FirstOrDefault(p => p.Key == "IsLocalRoot").Value, "False");
}

It says "Unexpected error detected". Output Pane doesn't help either.

The active Test Run was aborted because the execution process exited unexpectedly. To investigate further, enable local crash dumps either at the machine level or for process vstest.executionengine.x86.exe.

By the way, before you say anything about the unit testing purposes I may be doing it wrong, but my purpose of Unit testing is like documentation. I am just doing it in order to clearly see what to expect from which unit.

Aucun commentaire:

Enregistrer un commentaire