public void CreateQueue_withDefaults_Cleanup() { if (!TestConfig.Run_MiscTests) { Assert.Inconclusive(); } AuthToken at = new AuthToken(Properties.Settings.Default.ManageKey, Properties.Settings.Default.ServiceNamespace); Queues q = new Queues(at); q.Delete("qWithDefaults"); }
public void CreateQueue_byCustomDefinition() { if (!TestConfig.Run_MiscTests) { Assert.Inconclusive(); } AuthToken at = new AuthToken(Properties.Settings.Default.ManageKey, Properties.Settings.Default.ServiceNamespace); Queues q = new Queues(at); QueueDefinition qd = new QueueDefinition("qFromCustomDef"); qd.MaxDeliveryCount = 10; qd.LockDuration = new TimeSpan(0, 0, 5); qd.MaxSizeInMegabytes = 5120; qd.DeadLetteringOnMessageExpiration = false; qd.DefaultMessageTimeToLive = new TimeSpan(0, 0, 30); qd.DuplicateDetectionHistoryTimeWindow = new TimeSpan(0, 0, 15); q.Create("qFromCustomDef", qd); q.Delete("qFromCustomDef"); }
public void Create101Cues_Cleanup() { if (!TestConfig.Run_Create101Cues) { return; } AuthToken at = new AuthToken(Properties.Settings.Default.ManageKey, Properties.Settings.Default.ServiceNamespace); Queues q = new Queues(at); DateTime startDt = DateTime.Now; try { Console.WriteLine(String.Format("Create101Cues test cleanup started @ {0} {1}", startDt.ToLongDateString(), startDt.ToLongTimeString())); List<string> qNames = GenerateQNames; foreach (string qName in qNames) { try { q.Delete(qName); } catch { // do nothing, let clean-up complete. } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { Console.WriteLine(String.Format("Time Elapsed: {0} seconds", (DateTime.Now - startDt).TotalSeconds)); } }
public void CreateQueue_FromDefinition() { if (!TestConfig.Run_CreateQueueFromDefinition) { Assert.Inconclusive("Test skipped."); return; } AuthToken at = new AuthToken(Properties.Settings.Default.ManageKey, Properties.Settings.Default.ServiceNamespace); Queues q = new Queues(at); #region "Pre-test clean-up" try { q.Delete("qWithDefaults"); q.Delete("qWithDefaults2"); } catch { // Do nothing. } #endregion q.Create("qWithDefaults"); QueueDescription qd = null; int tries = 0; #region "Wait up to 10 seconds for the queue to publish." while (qd == null && tries < 10) { Thread.Sleep(1000); try { var tmp = q.AtomPubList().Entries.Where(x => x.Title == "qwithdefaults"); if (tmp != null) { if (tmp.Count() == 1) { AtomPubFeedEntry ape = tmp.First(); if (ape.Content != null) { if (ape.Content.Value != null) { qd = QueueDescription.DeserializeFrom(ape.Content.Value); } } } } } catch { // Do nothing. } finally { tries += 1; } } #endregion #region "Tried 10 x fail" if (tries == 10 && qd == null) { try { q.Delete("qWithDefaults"); } catch { Console.WriteLine("Failure to create and/or delete could constitute a problem with Azure and/or Service Bus and/or Internet connection."); Console.WriteLine("Could not clean-up: 'qWithDefaults' -- Suggest using Service Bus Explorer to remove this queue if it exists."); // Do nothing. } finally { Assert.Fail("Failed to retreive and/or delete newly created queue: 'qWithDefaults'"); } } #endregion q.Create("qWithDefaults2", new QueueDefinition("qWithDefaults2", qd)); QueueDescription qd2 = null; tries = 0; #region "Wait up to 10 seconds for the queue to publish." while (qd2 == null && tries < 10) { Thread.Sleep(1000); try { var tmp = q.AtomPubList().Entries.Where(x => x.Title == "qwithdefaults2"); if (tmp != null) { if (tmp.Count() == 1) { AtomPubFeedEntry ape = tmp.First(); if (ape.Content != null) { if (ape.Content.Value != null) { qd2 = QueueDescription.DeserializeFrom(ape.Content.Value); } } } } } catch // (Exception ex) { // Do nothing. } finally { tries += 1; } } #endregion #region "Tried 10 x fail" if (tries == 10 && qd2 == null) { try { q.Delete("qWithDefaults"); q.Delete("qWithDefaults2"); } catch { Console.WriteLine("Failure to create and/or delete could constitute a problem with Azure and/or Service Bus and/or Internet connection."); Console.WriteLine("Could not clean-up: 'qWithDefaults' and/or 'qWithDefaults2' -- Suggest using Service Bus Explorer to remove this queue if it exists."); // Do nothing. } finally { Assert.Fail("Failed to retreive and/or delete newly created queues: 'qWithDefaults', 'qWithDefaults2'"); } } #endregion try { QueueDefinition qdc1 = new QueueDefinition("qWithDefaults", qd); QueueDefinition qdc2 = new QueueDefinition("qWithDefaults2", qd2); Assert.AreEqual<QueueDefinition>(qdc1, qdc2); } finally { #region "Cleanup" q.Delete("qWithDefaults"); q.Delete("qWithDefaults2"); #endregion } }