Code Organisation and Unit Testing

Questions about MultiCharts .NET and user contributed studies.
maffers001
Posts: 3
Joined: 27 Aug 2018

Code Organisation and Unit Testing

Postby maffers001 » 27 Aug 2018

Hi,

I'm an experienced programmer but I'm new to C# and Multicharts.NET.

I've been coding some strategies in Multicharts.NET but it seems that I have to create all my functions and strategies in a single Multicharts folder and within the PowerLanguage namespace and that I must create new items in the Multicharts.NET editor rather than use Visual Studio. This makes it very difficult to organise and structure my code in a clear and sensible way.

Does anyone know if it is possible to use Visual Studio to organise Multicharts code into subfolders and/or different namepaces or if you can create a separate project for function code and have PLStudies2010 reference this? It's a real pain having one large mass of code in a single place.

I am also trying to create unit tests for my code, can anyone provide any pointers on how best to do this? Has anyone used a mocking framework to enable unit testing?

Many thanks,
Mathew.

maffers001
Posts: 3
Joined: 27 Aug 2018

Re: Code Organisation and Unit Testing

Postby maffers001 » 30 Aug 2018

Hi,

In case anyone is interested, I got around the need to mock parts of the MC framework by creating the calculation code as public nested classes within the function class. I then created a separate solution and project in Visual Studio for testing (PLStudies2010.Test) and used NUnit to test that calculations within my functions are producing the correct results.

Code organisation is still a problem but I've prefixed all custom code with my initials as a workaround. I noticed that the MC editor allows folders to be added but for some reason they disappear when MC is restarted.

Mathew.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Code Organisation and Unit Testing

Postby Henry MultiСharts » 30 Aug 2018

Hello Mathew,

For working with studies/solution/references, please see post #1 in MultiCharts .NET FAQ:
viewtopic.php?f=19&t=45848#p100789


Return to “MultiCharts .NET”