コード例 #1
0
ファイル: Describe.cs プロジェクト: scpex/harperdb_tester
        //[Fact]
        public async Task Describe_schema()
        {
            HDBClient client = new HDBClient();

            // Dictionary<string, string> jsonBody = new Dictionary<string, string>();
            // jsonBody.Add("operation", @"");
            // jsonBody.Add("sql", @"{select * from mycos.employees where id = '69c185dc-2392-45ab-b758-f7c51d1f3338'}");
            string query = @"{ ""operation"":""describe_schema"",""schema"":""northnwd"" }";

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

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

            dynamic schema = JsonConvert.DeserializeObject(content);

            Console.Out.WriteLine("Response: " + schema);
            // Assert.True(schema.)
            //Assert.NotNull(content);

            // Assert.False(content.Contains("Invalid"));
            // Assert.Equal("Test response", content);
            // Assert.False(response.Headers.Contains("Server"), "Should not contain server header");
        }
コード例 #2
0
ファイル: SQL_test.cs プロジェクト: scpex/harperdb_tester
        //[Fact]
        public async Task CreateSchemaAndTable()
        {
            HDBClient client = new HDBClient();
            string    query  = @"{ ""operation"":""create_schema"", ""schema"": ""sql"" }";

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

            if (responseContent.Contains("created"))
            {
                string tableQuery = @"{ ""operation"":""create_table"", ""schema"": ""sql"", ""table"":""dog"", ""hash_attribute"":""id"" }";
                Console.Out.WriteLine("Request: " + query);
                var tableResult = await client.PostAsync(HDBConfig.HDBServer, new StringContent(tableQuery, Encoding.UTF8, "application/json"));

                String tableResponseContent = await tableResult.Content.ReadAsStringAsync();

                Console.Out.WriteLine("ResponseJson: " + tableResponseContent);
            }
            else
            {
                Console.Out.WriteLine("ResponseJson: The schema was created!!!");
            }
        }
コード例 #3
0
ファイル: SQL_test.cs プロジェクト: scpex/harperdb_tester
        //[Fact]
        public async Task Delete_data()
        {
            HDBClient client = new HDBClient();
            string    query  = @"{ ""operation"":""sql"", ""sql"": ""DELETE FROM sql.dog WHERE name = 'Hugo'"" }";

            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);
        }
コード例 #4
0
ファイル: SQL_test.cs プロジェクト: scpex/harperdb_tester
        //[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);
        }
コード例 #5
0
ファイル: The_Tester.cs プロジェクト: scpex/harperdb_tester
        //[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);
        }
コード例 #6
0
ファイル: The_Tester.cs プロジェクト: scpex/harperdb_tester
        //[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);
        }
コード例 #7
0
ファイル: sql_tester2.cs プロジェクト: scpex/harperdb_tester
        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);
        }
コード例 #8
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);
        }
コード例 #9
0
ファイル: sql_tester2.cs プロジェクト: scpex/harperdb_tester
        //[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);
        }
コード例 #10
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);
        }
コード例 #11
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);
        }
コード例 #12
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");
        }