Пример #1
0
        public async Task CreateDeleteTopic()
        {
            IgnoreTestInLiveMode();
            //create topic
            string          topicName = Recording.GenerateAssetName("topic");
            ServiceBusTopic topic     = (await _topicCollection.CreateOrUpdateAsync(WaitUntil.Completed, 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.ExistsAsync(topicName));

            //delete topic
            await topic.DeleteAsync(WaitUntil.Completed);

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

            Assert.Null(topic);
            Assert.IsFalse(await _topicCollection.ExistsAsync(topicName));
        }
        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));
        }
Пример #3
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.ExistsAsync("bar"))
            {
                Console.WriteLine("topic 'bar' exists");
            }
            #endregion
        }