Unable to unit test the Project with MSTest

Hi,
I have created a WebAPI2 project with Unit tests out of the box.
IDE: VS2017
ASPOSE: 17.10
Windows 7
I’m getting the following execption from the unit test project:
Aspose.Words.UnsupportedFileFormatException: Unknown file format: Unknown
How ever if I just run my code everything works. Do I have to do something special if I want to implement UT when using Aspose?
Kr
Matthias

@matthias.coenen
Thanks for your inquiry. We have tested Unit Test scenario with Aspose.Words for .NET 17.10 and unable to notice any issue. We will appreciate it if you please share a sample project (without compilation error) along with input documents as ZIP file. We will look into the issue and will guide you accordingly.

Hi,
Please download the project friom here: https://we.tl/m8KaKIV4lf
Kr
Matthias

@matthias.coenen
Thanks for sharing the project. But, I am afraid I am unable to test it. While running main project I am getting “HTTP Error 403.14 - Forbidden” error. I tried different workarounds but no success. I will appreciate if you please share some details/steps to replicate the issue at our end.
We are sorry for the inconvenience.

Hi,
This is because this is only a WebAPI, there are no “html” page’s.
If you append the following /api/WordToPDF then you will hit controller.
Testing it will be difficult, because the “Input” has to be POST from a document stream.
This can be simulated with postman.
The problem is also with the “Unit test” and not with the applocation, the application works.
Hower if I run the unit test, Aspose throws an error.
Kr
Matthias

@matthias.coenen,
Thanks for your feedback. Please note you do not need any extra setting to use Aspose.Words related Unit Test. Furthermore, Aspose.Words throws UnsupportedFileFormat Exception when Dcoument() method gets an unsupported file or stream as parameter. Please double check the stream file format using DetectFileFormat and reset stream position as well before passing to Document() method. Hopefully it will help you to resolve the issue. However, if the issue persists then please share a working project to reproduce the issue at our end. You may also create a simple console application for purpose.

Aspose.Words.FileFormatInfo info = Aspose.Words.FileFormatUtil.DetectFileFormat(stream);

if (info.LoadFormat != LoadFormat.Docx)
    throw new Exception("The stream has invalid DOCX string.");

stream.Position = 0;

Document doc= new Document(stream);