示例#1
0
        public async Task CreateDeleteEventHub()
        {
            //create eventhub
            string   eventhubName = Recording.GenerateAssetName("eventhub");
            EventHub eventHub     = (await _eventHubCollection.CreateOrUpdateAsync(eventhubName, new EventHubData())).Value;

            Assert.NotNull(eventHub);
            Assert.AreEqual(eventHub.Id.Name, eventhubName);

            //validate if created successfully
            eventHub = await _eventHubCollection.GetIfExistsAsync(eventhubName);

            Assert.NotNull(eventHub);
            Assert.IsTrue(await _eventHubCollection.CheckIfExistsAsync(eventhubName));

            //delete eventhub
            await eventHub.DeleteAsync();

            //validate
            eventHub = await _eventHubCollection.GetIfExistsAsync(eventhubName);

            Assert.Null(eventHub);
            Assert.IsFalse(await _eventHubCollection.CheckIfExistsAsync(eventhubName));
        }
示例#2
0
        public async Task GetIfExist()
        {
            #region Snippet:Managing_EventHubs_GetEventHubIfExists
            EventHub eventHub = await eventHubCollection.GetIfExistsAsync("foo");

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