Example #1
0
        public async Task CreateTableAsync()
        {
            var projectId = "project";
            var datasetId = "dataset";
            var tableId = "table";
            var service = new FakeBigqueryService();
            var client = new BigqueryClientImpl(projectId, service);
            var reference = client.GetTableReference(projectId, datasetId, tableId);
            var schema = new TableSchemaBuilder {
                { "column", BigqueryDbType.Integer }
            }.Build();

            service.ExpectRequest(
                service.Tables.Insert(new Table {
                TableReference = reference, Schema = schema
            }, projectId, datasetId),
                new Table {
                TableReference = reference, Schema = schema
            });
            var result = await client.CreateTableAsync(reference, schema);

            Assert.Equal(projectId, result.Reference.ProjectId);
            Assert.Equal(datasetId, result.Reference.DatasetId);
            Assert.Equal(tableId, result.Reference.TableId);
            Assert.Equal("column", result.Schema.Fields[0].Name);
        }
Example #2
0
        public async Task DeleteTableAsync()
        {
            var projectId = "project";
            var datasetId = "dataset";
            var tableId   = "table";
            var service   = new FakeBigqueryService();
            var client    = new BigqueryClientImpl(projectId, service);
            var reference = client.GetTableReference(projectId, datasetId, tableId);

            service.ExpectRequest(
                service.Tables.Delete(projectId, datasetId, tableId),
                "OK");
            await client.DeleteTableAsync(reference);
        }
Example #3
0
        public async Task GetTableAsync()
        {
            var projectId = "project";
            var datasetId = "dataset";
            var tableId   = "table";
            var service   = new FakeBigqueryService();
            var client    = new BigqueryClientImpl(projectId, service);
            var reference = client.GetTableReference(projectId, datasetId, tableId);

            service.ExpectRequest(
                service.Tables.Get(projectId, datasetId, tableId),
                new Table {
                TableReference = reference
            });
            var result = await client.GetTableAsync(reference);

            Assert.Equal(projectId, result.Reference.ProjectId);
            Assert.Equal(datasetId, result.Reference.DatasetId);
            Assert.Equal(tableId, result.Reference.TableId);
        }