public void DeleteQueue()
        {
            WebRequestFactory requestFactory = ServiceBusHelper.GetWebRequestFactory();
            HttpWebRequest request = requestFactory.CreateWebRequest("DELETE", _queueUri);

            var webClient = new WebClientWrapper { ThrowOnHttpError = true };
            HttpWebResponse repsonse = webClient.SendRequest(request);
        }
        public QueueMessagesApiTests()
        {
            Uri serviceBusUri = ServiceBusHelper.GetLocalHttpsEndpoint();
            _uriCreator = new UriCreator(serviceBusUri);
            _webClient =  new WebClientWrapper();

            string queueName = Guid.NewGuid().ToString();
            _queueUri = _uriCreator.GenerateQueueUri(queueName);
        }
        public TopicMessagesApiTests()
        {
            Uri serviceBusUri = ServiceBusHelper.GetLocalHttpsEndpoint();
            _uriCreator = new UriCreator(serviceBusUri);
            _webClient =  new WebClientWrapper();

            string topicName = Guid.NewGuid().ToString();
            _topicUri = _uriCreator.GenerateTopicUri(topicName);
        }
        public void CreateSubscriptionAndSendOneMessage()
        {
            WebRequestFactory requestFactory = ServiceBusHelper.GetWebRequestFactory();
            var webClient = new WebClientWrapper { ThrowOnHttpError = true };

            XElement subscriptionDescription = ObjectDescriptionBuilder.CreateSubscriptionDescription(null);
            HttpWebRequest subscriptionRequest = requestFactory.CreateWebRequestWithData("PUT", _subscriptionUri, subscriptionDescription.ToString());
            HttpWebResponse subscriptionRepsonse = webClient.SendRequest(subscriptionRequest);
        }
        public SubscriptionApiTests()
        {
            Uri serviceBusUri = ServiceBusHelper.GetLocalHttpsEndpoint();
            _uriCreator = new UriCreator(serviceBusUri);
            _webClient =  new WebClientWrapper();
            _requestFactory = ServiceBusHelper.GetWebRequestFactory();

            _topicName = Guid.NewGuid().ToString();
            _topicUri = _uriCreator.GenerateTopicUri(_topicName);

            _subscriptionName = Guid.NewGuid().ToString();
            _subscriptionUri = _uriCreator.GenerateSubscriptionUri(_topicName, _subscriptionName);
        }
        public void CreateQueue()
        {
            var rule1 = new AccessRule { UserName = TestUsers.User1.UserName, ServiceBusNamespace = _serviceBusNamespace };
            rule1.Permissions.Add(AccessRight.Listen);
            rule1.Permissions.Add(AccessRight.Send);

            var rule2 = new AccessRule { UserName = TestUsers.User2.UserName, ServiceBusNamespace = _serviceBusNamespace };
            rule2.Permissions.Add(AccessRight.Listen);

            var rule3 = new AccessRule { UserName = TestUsers.User3.UserName, ServiceBusNamespace = _serviceBusNamespace };
            rule3.Permissions.Add(AccessRight.Send);

            var rules = new List<AccessRule> { rule1, rule2, rule3 };

            XElement queueDescription = ObjectDescriptionBuilder.CreateQueueDescription(rules);

            WebRequestFactory requestFactory = ServiceBusHelper.GetWebRequestFactory();
            HttpWebRequest request = requestFactory.CreateWebRequestWithData("PUT", _queueUri, queueDescription.ToString());

            var webClient = new WebClientWrapper { ThrowOnHttpError = true };
            HttpWebResponse repsonse = webClient.SendRequest(request);
        }
        public void DeleteSubscription()
        {
            WebRequestFactory requestFactory = ServiceBusHelper.GetWebRequestFactory();
            var webClient = new WebClientWrapper { ThrowOnHttpError = true };

            HttpWebRequest subscriptionRequest = requestFactory.CreateWebRequest("DELETE", _subscriptionUri);
            HttpWebResponse subscriptionRepsonse = webClient.SendRequest(subscriptionRequest);
        }