Reputation: 4388
Our application integrates with a WCF webservice through a dll reference and WCF configuration entries in the client application's web.config. When I try to mock the webservice I receive an "Could not find default endpoint element that references contract 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 co..." error. To resolve the issue, I have added the corresponding bindings from the web.config into the test project's app.config file and set it to "copy always" so it is copied to the bin\debug folder but I still get the error. How should I resolve this issue?
using Payments.ServiceReferences.PaymentServiceProxy;
public interface IPaymentsAPIClientGenerator
{
PaymentServiceClient PaymentServiceClient { get; }
}
using Payments.ServiceReferences.PaymentServiceProxy;
public class PaymentsAPIClientGenerator : IPaymentsAPIClientGenerator
{
public PaymentsAPIClientGenerator()
{
}
public PaymentServiceClient PaymentServiceClient
{
get
{
var paymentServiceClient = PaymentVaultProxyFactory.GeneratePaymentServiceClient();
return paymentServiceClient;
}
}
}
[TestMethod]
public void IfTheSecondPaymentFailsThenTheFirstPaymentShouldBeVoided()
{
//Arrange
var iPaymentsAPIClientGeneratorMock = new Mock<IPaymentsAPIClientGenerator>();
var paymentServiceClient = new Mock<PaymentServiceClient>();
iPaymentsAPIClientGeneratorMock.SetupGet(counter => counter.PaymentServiceClient).Returns(paymentServiceClient.Object);
}
Upvotes: 0
Views: 595
Reputation: 15175
The web.config for the project that generated that dll should have the binding configuration. If you reference the dll as a project reference in vs then it should use whatever setting was built in, otherwise, the most straight forward solution would be to copy the binding to your test application's configuration.
Upvotes: 1