public DummyHttpEndpointTest() { _ctrl = new DummyController(); _serviceV1 = new DummyCommandableHttpService(); _serviceV2 = new DummyCommandableHttpService(); _httpEndpoint = new HttpEndpoint(); var references = References.FromTuples( new Descriptor("pip-services3-dummies", "controller", "default", "default", "1.0"), _ctrl, new Descriptor("pip-services3", "endpoint", "http", "default", "1.0"), _httpEndpoint ); _serviceV1.Configure(ConfigParams.FromTuples( "base_route", "/api/v1/dummy" )); _serviceV2.Configure(ConfigParams.FromTuples( "base_route", "/api/v2/dummy" )); _httpEndpoint.Configure(RestConfig); _serviceV1.SetReferences(references); _serviceV2.SetReferences(references); _httpEndpoint.OpenAsync(null).Wait(); }
public async Task It_Should_Return_OpenApi_FileAsync() { // create temp file var openApiContent = "swagger yaml content from file"; var fileName = Path.GetTempFileName(); File.WriteAllText(fileName, openApiContent); // recreate service with new configuration await _httpEndpoint.CloseAsync(null); await _service.CloseAsync(null); _httpEndpoint = new HttpEndpoint(); _service = CreateService(_httpEndpoint, ConfigParams.FromTuples( "base_route", "/api/v1", "openapi_file", fileName, // for test only "swagger.enable", "true" )); _httpEndpoint.Configure(RestConfig); await _httpEndpoint.OpenAsync(null); var result = await SendRequestAsync("get", "/api/v1/swagger", new { }); Assert.Equal(openApiContent, result); File.Delete(fileName); }
public DummyRestServiceTest() { _httpClient = new HttpClient(); _httpEndpoint = new HttpEndpoint(); _service = CreateService(_httpEndpoint, ServiceConfig); _httpEndpoint.Configure(RestConfig); _httpEndpoint.OpenAsync(null).Wait(); }
private HttpEndpoint CreateLocalEndpoint() { var endpoint = new HttpEndpoint(); if (_config != null) { endpoint.Configure(_config); } if (_references != null) { endpoint.SetReferences(_references); } return(endpoint); }
public async Task It_Should_Return_OpenApi_ResourceAsync() { var openApiContent = "swagger yaml content from resource"; // recreate service with new configuration await _httpEndpoint.CloseAsync(null); await _service.CloseAsync(null); _httpEndpoint = new HttpEndpoint(); _service = CreateService(_httpEndpoint, ConfigParams.FromTuples( "base_route", "/api/v1", "openapi_resource", "DummyRestServiceSwagger.yaml", // for test only "swagger.enable", "true" )); _httpEndpoint.Configure(RestConfig); await _httpEndpoint.OpenAsync(null); var result = await SendRequestAsync("get", "/api/v1/swagger", new { }); Assert.Equal(openApiContent, result); }