private void QueueDeleteIfExist(string name) { if (MhQueue.IsQueueExist(Name)) { MhQueue.Delete(name); } }
public void QueueDelete() { QueueDeleteIfExist(Name); MhQueue.Create(Name); MhQueue.Delete(Name); }
public void MessageGetAll() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); var messages = new List <string> { "test 1", "test 2", "test 3" }; foreach (var message in messages) { queue.Send(message); } var mhMessages = queue.GetMessages(); foreach (var mhMessage in mhMessages) { if (!messages.Contains(mhMessage.Body.ToString())) { Assert.Fail(); } } Assert.AreEqual(mhMessages.Count(), 3); }
private void button1_Click(object sender, EventArgs e) { try { Book book = new Book( textBox1.Text, textBox2.Text, textBox3.Text, Convert.ToInt32(textBox4.Text), textBox5.Text, textBox6.Text); if (listBox1.SelectedItem != null) { string name = listBox1.SelectedItem.ToString(); int pos = name.LastIndexOf("\\"); name = name.Substring(pos + 1, name.Length - pos - 1); MhQueue queue = new MhQueue(name); queue.Send(book); } else { MessageBox.Show("Choose queue"); } } catch (Exception er) { } }
private void button2_Click(object sender, EventArgs e) { listBox1.Items.Clear(); foreach (MessageQueue q in MhQueue.GetAllQueues()) { listBox1.Items.Add(q.Path); } }
public void QueueExist() { QueueDeleteIfExist(Name); MhQueue.Create(Name); bool isExist = MhQueue.IsQueueExist(Name); Assert.IsTrue(isExist); }
private void button4_Click(object sender, EventArgs e) { string name = listBox1.SelectedItem.ToString(); int pos = name.LastIndexOf("\\"); name = name.Substring(pos + 1, name.Length - pos - 1); MhQueue queue = new MhQueue(name); queue.Purge(); button2_Click(sender, e); }
public void MessagePeek() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); queue.Send("test 1"); queue.Peek(); var count = queue.Count; Assert.AreEqual(count, 1); }
public void MessageSendWithEmptyLabel() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); string msg = "test"; queue.Send(msg); var count = queue.Count; Assert.AreEqual(count, 1); }
public void MessagePeekById() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); queue.Send("test 1"); var msg1 = queue.Peek(); var msg2 = queue.Peek(msg1.Id); Assert.AreEqual(msg1.Id, msg2.Id); }
public void Purge() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); queue.Send("test 1"); queue.Send("test 2"); queue.Send("test 2"); queue.Purge(); Assert.AreEqual(queue.Count, 0); }
public void MessageSend() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); string msg = "test"; string label = "group a"; queue.Send(msg, label); var count = queue.Count; Assert.AreEqual(count, 1); }
public void MessageReceive() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); string msg = "test"; string label = "group a"; queue.Send(msg, label); var msgOut = queue.Receive(); Assert.AreEqual(msg, msgOut.Body); }
public void MessageCount() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); queue.Send("test 1"); queue.Send("test 2"); queue.Send("test 2"); int count = queue.Count; Assert.AreEqual(count, 3); }
private static void DeleteQueue() { try { Console.WriteLine("\n\tEnter name of queue:"); string name = Console.ReadLine(); MhQueue.Delete(name); Console.WriteLine($"The {name} was deleted succesfully"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void MessageReceiveById() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); queue.Send("test 1"); queue.Send("test 2"); queue.Send("test 3"); var msgOut = queue.Peek(); queue.Receive(msgOut.Id); var count = queue.Count; Assert.AreEqual(count, 2); }
private static void PeekMessage() { try { Console.WriteLine("\n\tEnter name of queue:"); string name = Console.ReadLine(); MhQueue queue = new MhQueue(name); var message = queue.Peek(); Console.WriteLine($"Message: {message.Body} SentTime: {message.SentTime}"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void MessageReceiveByTimePositive() { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); string msg = "test"; TimeSpan timeout = new TimeSpan(0, 0, 3); Task.Run(() => { Thread.Sleep(1000); queue.Send(msg); }); var msgOut = queue.Receive(timeout); Assert.AreEqual(msg, msgOut.Body); }
private static void DeleteAllMessages() { try { Console.WriteLine("\n\tEnter name of queue:"); string name = Console.ReadLine(); MhQueue queue = new MhQueue(name); queue.Purge(); Console.WriteLine("Messages were deleted succesfully"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
private static void PeekAll() { try { Console.WriteLine("\n\tEnter name of queue:"); string name = Console.ReadLine(); MhQueue queue = new MhQueue(name); IEnumerable <IMhMessage> messages = queue.GetMessages(); foreach (var message in messages) { Console.WriteLine($"Message: {message.Body} SentTime: {message.SentTime}"); } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
private void button2_Click(object sender, EventArgs e) { try { string name = listBox1.SelectedItem.ToString(); int pos = name.LastIndexOf("\\"); name = name.Substring(pos + 1, name.Length - pos - 1); richTextBox1.Text = ""; MhQueue queue = new MhQueue(name); IEnumerable <IMhMessage> messages = queue.GetMessages(); foreach (var message in messages) { richTextBox1.Text += message.Body.ToString(); } } catch (Exception ex) { richTextBox1.Text = ex.Message; } }
private static void SendMessage() { try { Console.WriteLine("\n\tEnter name of queue:"); string name = Console.ReadLine(); Console.WriteLine("\n\tEnter message:"); string message = Console.ReadLine(); Console.WriteLine("\n\tEnter label:"); string label = Console.ReadLine(); MhQueue queue = new MhQueue(name); queue.Send(message, label); Console.WriteLine($"The {message} was sent succesfully"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public void MessageReceiveByTimeNegative() { try { QueueDeleteIfExist(Name); var queue = MhQueue.Create(Name); string msg = "test"; TimeSpan timeout = new TimeSpan(0, 0, 1); Task.Run(() => { Thread.Sleep(3000); queue.Send(msg); }); queue.Receive(timeout); } catch (Exception) { Assert.IsTrue(true); } }