Exemplo n.º 1
0
        public void MessageSequenceTest()
        {
            TestMessageToSend.created               = new List <TestMessageToSend>();
            TestMessageToSend.TotalSendsCounter     = 0;
            TestMessageToSend.TotalCreationsCounter = 0;
            TestMessageToSend.RecipientNumber       = 30;
            TestMessageToSend.MessageNumber         = 300;
            SendSomeMessages(500, 10, 30);
            Assert.IsTrue(TestMessageToSend.TotalSendsCounter == TestMessageToSend.TotalCreationsCounter);
            List <double> diffs_ms    = new List <double>();
            List <int>    diffs_count = new List <int>();

            for (long RecNumber = 0; RecNumber < TestMessageToSend.RecipientNumber; RecNumber++)
            {
                List <TestMessageToSend> PersonMessages = TestMessageToSend.created.FindAll(item => item.GetChatId() == RecNumber);
                for (int i = 1; i < PersonMessages.Count; i++)
                {
                    TestMessageToSend mes2    = PersonMessages[i];
                    TestMessageToSend mes1    = PersonMessages[i - 1];
                    double            diff_ms = mes2.SendingTime.Subtract(mes1.SendingTime).TotalMilliseconds;
                    int diff_count            = mes2.GetMessageNumber() - mes1.GetMessageNumber();
                    diffs_ms.Add(diff_ms);
                    diffs_count.Add(diff_count);
                }
            }
            var q1 = diffs_ms.FindAll(item => item < 0);
            var q2 = diffs_count.FindAll(item => item != 1);

            Assert.IsTrue(q1.Count < 0.01 * TestMessageToSend.created.Count && q2.Count == 0);
        }
Exemplo n.º 2
0
 public static void MessageCreation()
 {
     for (long iter = FirstRecipient; iter < FirstRecipient + RecipientNumber; iter++)
     {
         for (int MessNumber = FirstMessageNumber; MessNumber < FirstMessageNumber + MessageNumber; MessNumber++)
         {
             int ampl = (int)(rnd.NextDouble() * SendingDelayAmplitude);
             TestMessageToSend mes = new TestMessageToSend(iter, ampl, MessNumber);
             sender.Put(mes);
             created.Add(mes);
             TotalCreationsCounter++;
         }
     }
 }
Exemplo n.º 3
0
        private static void SendSomeMessages(int MessagesPerTick, double SendingInterval,
                                             int SendingDelayAmplitude)
        {
            TestMessageToSend.TotalSendsCounter     = 0;
            TestMessageToSend.sender                = new Sender(MessagesPerTick, SendingInterval);
            TestMessageToSend.SendingDelayAmplitude = SendingDelayAmplitude;
            TestMessageToSend.MessageCreation(1);
            TestMessageToSend.sender.Start();

            DateTime   dt     = DateTime.UtcNow;
            List <int> scores = new List <int>();

            while (TestMessageToSend.sender.GetMaxPriorQuenueSize() != 0
                   | TestMessageToSend.sender.GetMainQuenueSize() != 0)
            {
                System.Threading.Thread.Sleep(TestMessageToSend.SamplingInterval);
            }
        }