internal static void TestMessages(AbstractClient C) { C.QueueMessage(P1); C.QueueMessage(P2); var Messages = C.GetMessages(); C.QueueMessage(null); Assert.That(Messages.Count == 2, "Dummy client's message adding error! Null message should not be queued"); Assert.That(Messages.Contains(P2), "Dummy client's message adding error!"); Assert.False(Messages.Contains(P3), "Dummy client's message checking error!"); // External modification must not affect internal operation Messages.Enqueue(P3); Assert.False(C.GetMessages().Contains(P3), "Dummy client's GetMessages should not return the internal list!"); }
internal static void TestMessageConcurrency(AbstractClient C) { const int Iterations = 10000; new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); // No exception should be thrown Assert.Pass(); }
internal static void TestMessages(AbstractClient C) { C.QueueMessage(P1); C.QueueMessage(P2); var Messages = C.GetMessages(); C.QueueMessage(null); Assert.That(Messages.Count == 2, "Dummy client's message adding error! Null message should not be queued"); Assert.That(Messages.Contains(P2), "Dummy client's message adding error!"); Assert.False(Messages.Contains(P3), "Dummy client's message checking error!"); // External modification must not affect internal operation Messages.Enqueue(P3); Assert.False(C.GetMessages().Contains(P3), "Dummy client's GetMessages should not return the internal list!"); }
internal static void TestMessageConcurrency(AbstractClient C) { const int Iterations = 10000; new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); new Thread(new ThreadStart(() => { for (int i = 0; i < Iterations; i++) { C.QueueMessage(RandomPayload()); } })).Start(); // No exception should be thrown Assert.Pass(); }