ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  ChartDirector .NET and MSTest
Posted by Matthew Nichols on Jan-17-2014 04:41
I am writing a class that generates charts using the .NET version of ChartDirector. While writing my unit tests in MSTest, ChartDirector was not finding my chartdir.lic file.

I checked the Chart.getBootLog() and got "2014-01-16 13:14:24> Cannot load license file C:\\\\WorkingFiles\\\\CacheMatrixPlatform_Baseline\\\\6.14.0\\\\TestResults\\\\Deploy_mnichols 2014-01-16 13_14_18\\\\Outchartdir.lic - file not found\\nCannot load license file C:\\\\Windows\\\\system32/chartdir.lic - file not found\\n".
(The getBootLog method is a very nice feature.)

Looking at the log it looks to me like when MSTest sets the AppDomain.CurrentDomain.BaseDirectory they do not add a trailing "\\" and that ChartDirector doesn't check but just concatenates "chartdir.lic".

Work around: I fixed my tests by adding a test class initialize that adds the trailing slash to AppDomain.CurrentDomain.BaseDirectory:
[ClassInitialize]
public static void Initialize(TestContext context)
{
    AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "\\\\");
}

This looks like a minor bug to me, but as long as I don't run into problems with it elsewhere I probably don't care.  But maybe this will be helpful to someone else.

Regards
Matthew Nichols

  Re: ChartDirector .NET and MSTest
Posted by Peter Kwan on Jan-18-2014 00:00
Hi Matthew,

Thanks a lot for reporting this issue to us. We will fix it in the next version of ChartDirector.

In our own code, we do not add a slash because even in Microsoft's own sample code, the
slash is often not added. I think a similar issue (about the lack of trailing slash of
AppDomain.CurrentDomain.BaseDirectory in MSText) is reported to Microsoft as a bug:

http://connect.microsoft.com/VisualStudio/feedback/details/580830/resolving-of-
siteoforigin-uri-paths-does-not-work-properly

For our case, we cannot assume the file system separator or the Path.Combine can be used
to combine the path, because the path may not be a file system path (a URI path is also
possible), so we may need to examine more carefully to work around it in the general case.
But for your case, I think your method should work fine.

Again, thanks a lot for reporting this to us.

Regards
Peter Kwan

  Re: ChartDirector .NET and MSTest
Posted by Matthew Nichols on Jan-18-2014 06:28
Peter

That makes sense.  Given that it is only an issue with unit testing and can be worked around it seems that you made the best all around choice.  And I agree that it is more of an MS Test bug.

Thanks for a very nice product.

Matthew