コード例 #1
0
        public async Task TableCreateAndUpdate()
        {
            var table = await CreateTable(null);

            Assert.AreEqual(_databaseName, table.Data.Resource.Id);
            // Seems bug in swagger definition
            //Assert.AreEqual(TestThroughput1, database.Data.Options.Throughput);

            bool ifExists = await TableCollection.ExistsAsync(_databaseName);

            Assert.True(ifExists);

            // NOT WORKING API
            //ThroughputSettingsData throughtput = await database.GetMongoDBCollectionThroughputAsync();
            CosmosTable table2 = await TableCollection.GetAsync(_databaseName);

            Assert.AreEqual(_databaseName, table2.Data.Resource.Id);
            //Assert.AreEqual(TestThroughput1, database2.Data.Options.Throughput);

            VerifyTables(table, table2);

            // TODO: use original tags see defect: https://github.com/Azure/autorest.csharp/issues/1590
            TableCreateUpdateData updateOptions = new TableCreateUpdateData(AzureLocation.WestUS, table.Data.Resource)
            {
                Options = new CreateUpdateOptions {
                    Throughput = TestThroughput2
                }
            };

            table = (await TableCollection.CreateOrUpdateAsync(WaitUntil.Completed, _databaseName, updateOptions)).Value;
            Assert.AreEqual(_databaseName, table.Data.Resource.Id);
            table2 = await TableCollection.GetAsync(_databaseName);

            VerifyTables(table, table2);
        }
コード例 #2
0
        public async Task TearDown()
        {
            CosmosTable table = await TableCollection.GetIfExistsAsync(_databaseName);

            if (table != null)
            {
                await table.DeleteAsync(WaitUntil.Completed);
            }
        }
コード例 #3
0
 private void VerifyTables(CosmosTable expectedValue, CosmosTable actualValue)
 {
     Assert.AreEqual(expectedValue.Id, actualValue.Id);
     Assert.AreEqual(expectedValue.Data.Name, actualValue.Data.Name);
     Assert.AreEqual(expectedValue.Data.Resource.Id, actualValue.Data.Resource.Id);
     Assert.AreEqual(expectedValue.Data.Resource.Rid, actualValue.Data.Resource.Rid);
     Assert.AreEqual(expectedValue.Data.Resource.Ts, actualValue.Data.Resource.Ts);
     Assert.AreEqual(expectedValue.Data.Resource.Etag, actualValue.Data.Resource.Etag);
 }