public void ChekMessageTaskStopProcessingMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessageTaskStopProcessingMessage")) { MessageQueue.Create(@".\private$\ChekMessageTaskStopProcessingMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageTaskStopProcessingMessage"); testQueue.Formatter = new BinaryMessageFormatter(); Task task = new Task("test", 1); List <Thread> listThread = new List <Thread>(); Agent.tasksList.Add(task); Agent.threadDictionary.Add(1, listThread); TaskStopProcessingMessage testMessage = new TaskStopProcessingMessage(0, 0, 1); testQueue.Send(testMessage); Assert.AreEqual((int)EnumTypeMessage.TaskStopProcessingMessage, ProcessingMessage.ChekMessage(testQueue)); Assert.AreEqual(0, Agent.tasksList.Count); MessageQueue.Delete(@".\private$\ChekMessageTaskStopProcessingMessage"); }
public void ChekMessageTestHalloMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessageTestReceiveHalloMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestReceiveHalloMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageTestReceiveHalloMessage"); testQueue.Formatter = new BinaryMessageFormatter(); SystemInformation info = new SystemInformation(); HalloMessage testMessage = new HalloMessage(0, 0, info); testQueue.Send(testMessage); Thread testThread = new Thread(testChekMessageReceiveHalloMessage); testThread.Start(); Assert.AreEqual(ProcessingMessage.ChekMessage(testQueue), (int)EnumTypeMessage.HelloMessage); MessageQueue.Delete(@".\private$\ChekMessageTestReceiveHalloMessage"); MessageQueue.Delete(@".\private$\secondrecive1"); MessageQueue.Delete(@".\private$\secondsend1"); }
public void ChekMessageTestExitMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessageTestExitMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestExitMessage"); } if (!MessageQueue.Exists(@".\private$\ChekMessageTestExitSendMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestExitSendMessage"); } if (!MessageQueue.Exists(@".\private$\ChekMessageTestExitReciveMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestExitReciveMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageTestExitMessage"); testQueue.Formatter = new BinaryMessageFormatter(); ExitMessage testMessage = new ExitMessage(0, 0); testQueue.Send(testMessage); Agent agent = new Agent(0, null, @".\private$\ChekMessageTestExitSendMessage", @".\private$\ChekMessageTestExitReciveMessage"); ProcessingMessage.agentsList.Add(agent); agent.SetConnect(); Assert.AreEqual(ProcessingMessage.ChekMessage(testQueue), (int)EnumTypeMessage.ExitMessage); MessageQueue.Delete(@".\private$\ChekMessageTestExitMessage"); }
public void ChekMessageTestEmptyMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessageTestEmptyMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestEmptyMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageTestEmptyMessage"); testQueue.Formatter = new BinaryMessageFormatter(); Communication.Message testMessage = new Communication.Message(0, 0); testQueue.Send(testMessage); Assert.AreEqual(ProcessingMessage.ChekMessage(testQueue), (int)EnumTypeMessage.Message); MessageQueue.Delete(@".\private$\ChekMessageTestEmptyMessage"); }
public void ChekMessageMessageNotExist() { if (!MessageQueue.Exists(@".\private$\ChekMessageMessageNotExist")) { MessageQueue.Create(@".\private$\ChekMessageMessageNotExist"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageMessageNotExist"); testQueue.Formatter = new BinaryMessageFormatter(); int message = 15; testQueue.Send(message); Assert.AreEqual(-1, ProcessingMessage.ChekMessage(testQueue)); MessageQueue.Delete(@".\private$\ChekMessageMessageNotExist"); }
public void ChekMessageTestReceiveTaskMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessageTestReceiveTaskMessage")) { MessageQueue.Create(@".\private$\ChekMessageTestReceiveTaskMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessageTestReceiveTaskMessage"); testQueue.Formatter = new BinaryMessageFormatter(); Task task = new Task("", 0); TaskMessage testMessage = new TaskMessage(0, 0, task, "a", "b"); testQueue.Send(testMessage); Assert.AreEqual(ProcessingMessage.ChekMessage(testQueue), (int)EnumTypeMessage.TaskMessage); MessageQueue.Delete(@".\private$\ChekMessageTestReceiveTaskMessage"); }
public void ChekMessagePingMessagMessage() { if (!MessageQueue.Exists(@".\private$\ChekMessagePingMessagMessage")) { MessageQueue.Create(@".\private$\ChekMessagePingMessagMessage"); } MessageQueue testQueue = new MessageQueue(@".\private$\ChekMessagePingMessagMessage"); testQueue.Formatter = new BinaryMessageFormatter(); PingMessage pingMessage = new PingMessage(0, 0); testQueue.Send(pingMessage); Agent.QueueSend = testQueue; Assert.AreEqual(ProcessingMessage.ChekMessage(testQueue), (int)EnumTypeMessage.PingMessage); MessageQueue.Delete(@".\private$\ChekMessagePingMessagMessage"); }