public async Task Delete() { #region Snippet:Managing_ServiceBusTopics_DeleteTopic ServiceBusTopicResource serviceBusTopic = await serviceBusTopicCollection.GetAsync("myTopic"); await serviceBusTopic.DeleteAsync(WaitUntil.Completed); #endregion }
public async Task CreateDeleteTopic() { IgnoreTestInLiveMode(); //create topic string topicName = Recording.GenerateAssetName("topic"); ServiceBusTopicResource topic = (await _topicCollection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, new ServiceBusTopicData())).Value; Assert.NotNull(topic); Assert.AreEqual(topic.Id.Name, topicName); //validate if created successfully Assert.IsTrue(await _topicCollection.ExistsAsync(topicName)); topic = await _topicCollection.GetAsync(topicName); //delete topic await topic.DeleteAsync(WaitUntil.Completed); //validate var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await _topicCollection.GetAsync(topicName); }); Assert.AreEqual(404, exception.Status); Assert.IsFalse(await _topicCollection.ExistsAsync(topicName)); }