Пример #1
0
        public DummyCommandableHttpClientTest()
        {
            _ctrl = new DummyController();

            _service = new DummyCommandableHttpService();

            _client = new DummyCommandableHttpClient();

            var references = References.FromTuples(
                new Descriptor("pip-services3-dummies", "controller", "default", "default", "1.0"), _ctrl,
                new Descriptor("pip-services3-dummies", "service", "rest", "default", "1.0"), _service,
                new Descriptor("pip-services3-dummies", "client", "rest", "default", "1.0"), _client
                );

            _service.Configure(RestConfig);
            _client.Configure(RestConfig);

            _client.SetReferences(references);
            _service.SetReferences(references);

            _service.OpenAsync(null).Wait();

            _fixture = new DummyClientFixture(_client);

            _source = new CancellationTokenSource();

            _client.OpenAsync(null).Wait();
        }
Пример #2
0
        public void TestNoHostPortUriSet()
        {
            var restConfig = ConfigParams.FromTuples(
                "connection.protocol", "http",
                "connection.port", "0"          // default is 8080
                );

            DummyController            _ctrl;
            DummyCommandableHttpClient _client;

            DummyCommandableHttpService _service;


            _ctrl = new DummyController();

            _service = new DummyCommandableHttpService();

            _client = new DummyCommandableHttpClient();

            var references = References.FromTuples(
                new Descriptor("pip-services3-dummies", "controller", "default", "default", "1.0"), _ctrl,
                new Descriptor("pip-services3-dummies", "service", "rest", "default", "1.0"), _service,
                new Descriptor("pip-services3-dummies", "client", "rest", "default", "1.0"), _client
                );

            _service.Configure(restConfig);
            _client.Configure(restConfig);

            _client.SetReferences(references);
            _service.SetReferences(references);

            _service.OpenAsync(null).Wait();


            var response = Record.ExceptionAsync(async() => await _client.OpenAsync(null));



            Assert.NotNull(response?.Result);
            var exception = Assert.IsType <ConfigException>(response.Result);

            Assert.Equal("NO_PORT", exception.Code);


            var task = _client.CloseAsync(null);

            task.Wait();

            task = _service.CloseAsync(null);
            task.Wait();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var controller = new DummyController();
            var service    = new DummyCommandableHttpService();
            var logger     = new ConsoleLogger();

            service.Configure(ConfigParams.FromTuples(
                                  "connection.protocol", "http",
                                  "connection.host", "localhost",
                                  "connection.port", 3000
                                  ));

            service.SetReferences(References.FromTuples(
                                      new Descriptor("pip-services3-dummies", "controller", "default", "default", "1.0"), controller,
                                      new Descriptor("pip-services3-dummies", "service", "rest", "default", "1.0"), service,
                                      new Descriptor("pip-services3-commons", "logger", "console", "default", "1.0"), logger
                                      ));

            service.OpenAsync(null).Wait();

            Console.WriteLine("Press ENTER to exit...");
            Console.ReadLine();
        }