0

I am trying to test a class in Service handler using NUnit project. My service handler class is part of a class library project which gets data from a WCF service. When call from test project method comes into service handler class and a method in that class tries to creat clients object with statement - using (Client client = new Client()), it throws exception : "Could not find default endpoint element that references contract 'XYZ' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

Loos like my app.config file is not being read in this case, thats why this exception is coming. has anybody ever faced this issue? I need urgent help regarding this.

Chat
  • 69
  • 2
  • 3
  • 12

2 Answers2

1

Add an App.Config to your NUnit assembly. Add the WCF service client config to the App.Config and it should work.

Nick Ryan
  • 2,662
  • 1
  • 17
  • 24
0

Rename app.config to the namespace of the Nunit Assembly that contains your tests, for example;

Namespace.Project.Class.config

namespace Namespace.Project.Class
{
    [TestFixture]
    public class Imports
    {
        [Test]
        public void InsertFile()
        {
        }
    }
}
ChrisBint
  • 12,773
  • 6
  • 40
  • 62
  • I tried this but still no luck... I read somewhere that instead of adding service refernce use web reference. I tried that also but then all proxy creation statements(i.e. Client client = new Client()) started throwing error for non - existence. – Chat Jul 07 '11 at 06:46