Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public DummyRestServiceTest()
        {
            _httpClient   = new HttpClient();
            _httpEndpoint = new HttpEndpoint();
            _service      = CreateService(_httpEndpoint, ServiceConfig);

            _httpEndpoint.Configure(RestConfig);
            _httpEndpoint.OpenAsync(null).Wait();
        }
Esempio n. 3
0
        private DummyRestService CreateService(HttpEndpoint httpEndpoint, ConfigParams config)
        {
            var service = new DummyRestService();

            var references = References.FromTuples(
                new Descriptor("pip-services3-dummies", "controller", "default", "default", "1.0"), new DummyController(),
                new Descriptor("pip-services3", "endpoint", "http", "default", "1.0"), httpEndpoint
                );

            service.Configure(config);
            service.SetReferences(references);
            return(service);
        }
Esempio n. 4
0
        public DummyRestServiceTest()
        {
            _ctrl    = new DummyController();
            _service = new DummyRestService();

            _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
                );

            _service.Configure(ConfigParams.FromTuples(
                                   "base_route", "/api/v1"
                                   ));

            _httpEndpoint.Configure(RestConfig);

            _service.SetReferences(references);

            _httpEndpoint.OpenAsync(null).Wait();
        }
Esempio n. 5
0
        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);
        }