public async Task GetService_ShouldReturn_ValidServiceAsync() { var expectedIdentityServiceModel = new DiscoveryServiceApiModel { ServiceUrl = "http://localhost/IdentityProviderSearchService", ServiceName = "IdentityProviderSearchService", Version = 1, DiscoveryType = "Service" }; var discoverySearchUrl = $"{_discoveryBaseUrl}Services?$filter=ServiceName eq '{expectedIdentityServiceModel.ServiceName}' and Version eq {expectedIdentityServiceModel.Version}"; _mockHttpHandler.Setup(httpHandler => httpHandler.Send(It.IsAny <HttpRequestMessage>())) .Returns((HttpRequestMessage requestMessage) => { if (requestMessage.RequestUri.ToString() .Equals(discoverySearchUrl, StringComparison.OrdinalIgnoreCase)) { return(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent( JsonConvert.SerializeObject( new DiscoveryServiceResponseModel { Context = $"{_discoveryBaseUrl}$metadata#Services", Value = new List <DiscoveryServiceApiModel> { expectedIdentityServiceModel } })) }); } return(new HttpResponseMessage { StatusCode = HttpStatusCode.BadRequest }); }); var discoveryServiceClient = new DiscoveryServiceClient("http://localhost/DiscoveryService/v1", _mockHttpHandler.Object); var serviceRegistration = await discoveryServiceClient.GetServiceAsync( expectedIdentityServiceModel.ServiceName, expectedIdentityServiceModel.Version); Assert.Equal(expectedIdentityServiceModel.ServiceUrl, serviceRegistration.ServiceUrl); }
/// <summary> /// Registers a service with DiscoveryService. /// </summary> /// <param name="discoveryServiceApi">The <see cref="DiscoveryServiceApiModel"/> to register.</param> /// <returns>A boolean value indicating success.</returns> public Task <bool> RegisterServiceAsync(DiscoveryServiceApiModel discoveryServiceApi) { throw new NotImplementedException(); }