コード例 #1
0
        public async Task CreateDeleteSchemaGroup()
        {
            //create schema group
            string          schemaGroupName = Recording.GenerateAssetName("schemagroup");
            SchemaGroupData parameters      = new SchemaGroupData()
            {
                SchemaType = SchemaType.Avro
            };
            SchemaGroupResource schemaGroup = (await _schemaGroupCollection.CreateOrUpdateAsync(WaitUntil.Completed, schemaGroupName, parameters)).Value;

            Assert.NotNull(schemaGroup);
            Assert.AreEqual(schemaGroupName, schemaGroup.Id.Name);

            //validate if created successfully
            Assert.IsTrue(await _schemaGroupCollection.ExistsAsync(schemaGroupName));
            schemaGroup = await _schemaGroupCollection.GetAsync(schemaGroupName);

            //delete eventhub
            await schemaGroup.DeleteAsync(WaitUntil.Completed);

            //validate
            var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await _schemaGroupCollection.GetAsync(schemaGroupName); });

            Assert.AreEqual(404, exception.Status);
            Assert.IsFalse(await _schemaGroupCollection.ExistsAsync(schemaGroupName));
        }