I want to write some integration tests to compare the WSDL generated by WCF services with previous (and published) versions. This is to ensure that service contracts do not differ from the time of issue.
I would like my tests to be self-contained and not rely on any external resources, such as hosting in IIS.
I think I could recreate my IIS hosting environment in a test with something like ...
using (ServiceHost host = new ServiceHost(typeof(NSTest.HelloNS), new Uri("http://localhost:8000/Omega"))) { host.AddServiceEndpoint(typeof(NSTest.IMy_NS), new BasicHttpBinding(), "Primary"); ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); behavior.HttpGetEnabled = true; host.Description.Behaviors.Add(behavior); host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); host.Open(); }
Does anyone have any other ideas?
EDIT: Obviously this code just creates a host for the service, I am still skipping the client code to get the WSDL definition.
source share