1

I am trying to test method in DAL of my web application with Fitnesse and FitSharp. I am having problems with reading app.config.

Getting error:

System.Reflection.TargetInvocationException: 
Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: 
Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: 
Object reference not set to an instance of an object. 
at ...DAL.get_ConnectionString()

This is in getter

get{
  var result = ConfigurationManager.ConnectionStrings["CN1"].ConnectionString;
  if (String.IsNullOrEmpty(result)) 
        throw new NoNullAllowedException("Connection string does not exist");
  return result;
}

Why ConfigurationManager is not initialized?

How to configure Fitnesse for testing DAL?

Thanks for any advice

Joe Bobson
  • 1,216
  • 15
  • 19

1 Answers1

1

I believe you'd need to make Fit Sharp aware of your App.config file:

c:\program files\fitsharp\runner -a c:\mypath\myapp.exe.config
   -c c:\myfolder\mysuite.config.xml
   -r fit.Runner.FolderRunner,c:\program files\fitsharp\fit.dll
Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
Serge Belov
  • 5,633
  • 1
  • 31
  • 40
  • Thanks. It works. I just want to add that app.config is case sensitive with fit runner. Tag ConnectionStrings must starts with lowercase: – Joe Bobson Dec 18 '12 at 10:40