public override void Run() { var clientSection = (ClientSection)GetConfig().GetSection("system.serviceModel/client"); var endpoints = clientSection.Endpoints; var endpoint = endpoints.OfType <ChannelEndpointElement>().FirstOrDefault(e => e.Name == EndpointName); if (endpoint == null) { throw new AssertionException(string.Format("Could not find Endpoint with name [{0}]", EndpointName)); } AssertState.Equal(ExpectedAddress, endpoint.Address.ToString(), "Address is incorrect"); AssertState.Equal(ExpectedBehaviourConfiguration, endpoint.BehaviorConfiguration, "BehaviourConfiguration is incorrect"); AssertState.Equal(ExpectedBinding, endpoint.Binding, "Binding is incorrect"); AssertState.Equal(ExpectedBindingConfiguration, endpoint.BindingConfiguration, "BindingConfiguration is incorrect"); AssertState.Equal(ExpectedContract, endpoint.Contract, "Contract is incorrect"); AssertState.Equal(ExpectedEndpointConfiguration, endpoint.EndpointConfiguration, "EndpointConfiguration is incorrect"); if (CheckConnectivity.GetValueOrDefault()) { var request = WebRequest.Create(ExpectedAddress); request.Timeout = (ConnectionTimeout ?? 10) * 1000; var webResponse = (HttpWebResponse)request.GetResponse(); AssertState.Equal(HttpStatusCode.OK, webResponse.StatusCode, "While attempting to check connectivity"); } }
public override void Run() { var servicesSection = (ServicesSection)GetConfig().GetSection("system.serviceModel/services"); var services = servicesSection.Services; if (services.Count == 0) { throw new AssertionException("No services section could be found."); } var serviceWasFound = false; foreach (ServiceElement se in services.Cast <ServiceElement>().Where(se => se.Name == ServiceName)) { serviceWasFound = true; Func <ServiceEndpointElement, bool> predicate; if (string.IsNullOrWhiteSpace(EndpointName)) { predicate = a => _addressMatchPredicate(a, ExpectedAddress); } else { predicate = a => _nameMatchPredicate(a, EndpointName); } var endpoint = se.Endpoints.OfType <ServiceEndpointElement>().FirstOrDefault(predicate); if (endpoint == null) { throw new AssertionException(string.Format("Could not find an Endpoint for Service [{0}] with the specified properties", ServiceName)); } AssertState.Equal(ExpectedAddress, endpoint.Address.ToString(), "Address is incorrect"); AssertState.Equal(ExpectedBehaviourConfiguration, endpoint.BehaviorConfiguration, "BehaviourConfiguration is incorrect"); AssertState.Equal(ExpectedBinding, endpoint.Binding, "Binding is incorrect"); AssertState.Equal(ExpectedBindingConfiguration, endpoint.BindingConfiguration, "BindingConfiguration is incorrect"); AssertState.Equal(ExpectedContract, endpoint.Contract, "Contract is incorrect"); AssertState.Equal(ExpectedEndpointConfiguration, endpoint.EndpointConfiguration, "EndpointConfiguration is incorrect"); } if (!serviceWasFound) { throw new AssertionException(string.Format("No Service found with Name [{0}]", ServiceName)); } if (CheckConnectivity.GetValueOrDefault()) { var request = WebRequest.Create(ExpectedAddress); request.Timeout = (ConnectionTimeout ?? 10) * 1000; var webResponse = (HttpWebResponse)request.GetResponse(); AssertState.Equal(HttpStatusCode.OK, webResponse.StatusCode, "While attempting to check connectivity"); request.Abort(); } }