Esempio n. 1
0
        //[Fact]
        public async Task Insert_data()
        {
            HDBClient client = new HDBClient();
            string    query  = @"{ ""operation"":""sql"", ""sql"": ""INSERT INTO sql.dog (id, name) VALUES(1, 'Simon')"" }";

            Console.Out.WriteLine("Request: " + query);
            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
        }
Esempio n. 2
0
        //[Fact]
        public async Task Update_Data()
        {
            var       dir    = Directory.GetCurrentDirectory();
            dynamic   query  = JsonConvert.DeserializeObject <dynamic>(File.ReadAllText(dir + Path.DirectorySeparatorChar + @"/tests/schema/dog_update.json"));
            HDBClient client = new HDBClient();

            Console.Out.WriteLine("Request: " + query);
            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query.ToString(), Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
            //Assert.Equal("Item not found!", responseJson.error);
        }
Esempio n. 3
0
        //[Fact]
        public async Task Describe_table()
        {
            HDBClient client = new HDBClient();

            string query = @"{ ""operation"":""describe_table"", ""table"":""dog"",""schema"": ""root"" }";

            Console.Out.WriteLine("Request: " + query);
            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("Response: " + responseJson);
            //Assert.Equal("Item not found!", responseJson.error);
        }
Esempio n. 4
0
        public async Task sql(string sql)
        {
            HDBClient client = new HDBClient();

            sql = "\"" + sql + "\"";
            string query = @"{""operation"":""sql"",""sql"":" + sql + "}";

            Console.Out.WriteLine("Request Body: " + query);
            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
        }
Esempio n. 5
0
        //[Fact]
        public async Task DropSchemaAndTable()
        {
            HDBClient client = new HDBClient();

            string query = @"{ ""operation"":""drop_schema"", ""schema"": ""jsonTests"" }";

            Console.Out.WriteLine("Request Body: " + query);

            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
        }
Esempio n. 6
0
        //[Fact]
        public async Task select_data_subdistrict()
        {
            HDBClient client = new HDBClient();

            string query = @"{""operation"":""sql"",""sql"":""select * from thailand.subdistrict""}";

            Console.Out.WriteLine("Request Body: " + query);

            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
            //Assert.Equal("Item not found!", responseJson.error);
        }
Esempio n. 7
0
        //[Fact]
        public async Task import_csvdata_customers()
        {
            HDBClient client = new HDBClient();

            string query = @"{""operation"":""csv_file_load"",""schema"":""northnwd"",""table"":""customers"",""file_path"": ""/home/code/databases/Customers.csv""}";

            Console.Out.WriteLine("Request Body: " + query);

            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
            //Assert.Equal("Item not found!", responseJson.error);
        }
Esempio n. 8
0
        public async Task create_table_customers()
        {
            HDBClient client = new HDBClient();

            string query = @"{""operation"":""create_table"",""schema"":""northnwd"",""table"":""customers"",""hash_attribute"": ""id""}";

            Console.Out.WriteLine("Request Body: " + query);

            var result = await client.PostAsync(HDBConfig.HDBServer, new StringContent(query, Encoding.UTF8, "application/json"));

            String responseContent = await result.Content.ReadAsStringAsync();

            dynamic responseJson = JsonConvert.DeserializeObject(responseContent);

            Console.Out.WriteLine("ResponseJson: " + responseJson);
            //Assert.Equal("Item not found!", responseJson);
        }
Esempio n. 9
0
        //[Fact]
        public async Task AddSimpleJson()
        {
            CreateSchemaAndTable().Wait();

            var dir = Directory.GetCurrentDirectory();

            dynamic json = JsonConvert.DeserializeObject <dynamic>(File.ReadAllText(dir + Path.DirectorySeparatorChar + @"basicjson.json"));

            HDBClient client = new HDBClient();

            var response = await client.PostAsync(HDBConfig.HDBServer, new StringContent(json.ToString(), Encoding.UTF8, "application/json"));

            response.EnsureSuccessStatusCode();

            var content = await response.Content.ReadAsStringAsync();

            Console.Out.WriteLine(content);

            DropSchemaAndTable().Wait();

            // Assert.Equal("Test response", content);
            // Assert.False(response.Headers.Contains("Server"), "Should not contain server header");
        }