I am testing my WCF services but I need to fake the behavior because my services are bootstrapped using a custom factory. This is the code I wrote for my test:
var channelFactory = new ChannelFactory<IDomainWriteService>(
new CustomBinding(
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement()),
new EndpointAddress(new Uri("local")));
var service = channelFactory.CreateChannel();
And I have a test initialize which is creating a new ServiceHost:
internal static void StartService()
{
Instance = new ServiceHost(typeof (DomainWriteService));
Instance.Open();
}
I have configured a fake endpoint in my MsTest project in the following way:
<service name="xxx.DomainWriteService">
<endpoint binding="basicHttpBinding" bindingConfiguration=""
name="local" bindingName="http" contract="xxx.IDomainWriteService" />
<host>
<baseAddresses>
<add baseAddress="http://xxx/service" />
</baseAddresses>
</host>
</service>
But when I run my tests I get this runtime error:
Class Initialization method xxx.ClassInitialize threw exception. System.ServiceModel.AddressAccessDeniedException:
System.ServiceModel.AddressAccessDeniedException:
HTTP could not register URL **http://+:80/service/**.
Your process does not have access rights to this namespace
(see http://go.microsoft.com/fwlink/?LinkId=70353 for details). --->
System.Net.HttpListenerException: Access is denied.
I am on Windows 8