0

I have a C# dll of type Class Library, which developed to be invoked by a third party Quartz application.

This C# dll creates a file, I would like to test creating the file without using Quartz. Any suggestion on what the easiest way to do that is?

I tried creating a Console application and invoked the dll, but that dll uses many other dlls and I'm getting the annoying (null reference) error whenever this dll invokes other dlls

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
bombo
  • 1,781
  • 6
  • 22
  • 25
  • 1
    If the DLL is using other DLL's you'll just have to put them all in the same folder. – Shadow The GPT Wizard Jan 17 '13 at 13:00
  • I've tried that but it's not really working :S – bombo Jan 17 '13 at 13:52
  • Try compiling all the DLL's in debug mode, then add the .pdb files as well. Having those will give you line numbers in the error's stack trace, see where it fails and fix it. – Shadow The GPT Wizard Jan 17 '13 at 13:59
  • Thanks for mentioning that, I've gone through them but none of the answers that I got was the answer that helped me with the issue. So that is why I haven't checked any of them as a correct answer – bombo Jan 17 '13 at 15:00
  • Shadow Wizard, can you write your comment as an answer so that I mark it as the right answer – bombo Jan 18 '13 at 12:37
  • 1
    If 50% of the questions you have asked are never answered, or answered incorrectly you should probably consider revising the questions. Like this question for example. You said that you wanted a way of testing the dll without Quartz. We gave you an answer to that question, but in reality you were looking for a different approach in debugging. Keep in mind that when other people will search and find this question, they will want to know the easiest way to test a C# dll without having to rely on Quartz. – eandersson Jan 19 '13 at 14:44

2 Answers2

3

I think it would be difficult for you to test the DLL directly without any dependencies. As an alternative I would suggest that you instead run isolated tests on the code using Unit Testing.

I would recommend that you take a look at this introduction to Unit Testing with Visual Studio.

Pablo Sarturi
  • 161
  • 1
  • 10
eandersson
  • 25,781
  • 8
  • 89
  • 110
1

You should develop a Unit test project. However, you will have to mock / stub out dependencies used by your class library. To do this efficiently you need to 'design' your class library to be easy to test.

For good advice, I can recommend the book 'The art of Unit Testing' by Roy Osherove.

You can try MStest (With some versions included with VS) or Nunit.

However if you are working with legacy or hard to test code, special frameworks can help you out to inject dependencies like external DLLs. One example is Typemock

Community
  • 1
  • 1
Myrtle
  • 5,761
  • 33
  • 47