Esempio n. 1
0
        public async Task CreateDeleteTopic()
        {
            IgnoreTestInLiveMode();
            //create topic
            string          topicName = Recording.GenerateAssetName("topic");
            ServiceBusTopic topic     = (await _topicCollection.CreateOrUpdateAsync(topicName, new ServiceBusTopicData())).Value;

            Assert.NotNull(topic);
            Assert.AreEqual(topic.Id.Name, topicName);

            //validate if created successfully
            topic = await _topicCollection.GetIfExistsAsync(topicName);

            Assert.NotNull(topic);
            Assert.IsTrue(await _topicCollection.CheckIfExistsAsync(topicName));

            //delete topic
            await topic.DeleteAsync();

            //validate
            topic = await _topicCollection.GetIfExistsAsync(topicName);

            Assert.Null(topic);
            Assert.IsFalse(await _topicCollection.CheckIfExistsAsync(topicName));
        }
Esempio n. 2
0
        public async Task GetIfExist()
        {
            #region Snippet:Managing_ServiceBusTopics_GetTopicIfExists
            ServiceBusTopic serviceBusTopic = await serviceBusTopicCollection.GetIfExistsAsync("foo");

            if (serviceBusTopic != null)
            {
                Console.WriteLine("topic 'foo' exists");
            }
            if (await serviceBusTopicCollection.CheckIfExistsAsync("bar"))
            {
                Console.WriteLine("topic 'bar' exists");
            }
            #endregion
        }