public void BuddyListModificationTest() { TimeSpan buddyListUpdateSleepTimeSpan = TimeSpan.FromSeconds(1); TimeSpan testTimeout = TimeSpan.FromSeconds(30); XMPPMessengerClient client1 = getTestClient("TestUser01"); Account account2 = getTestAccount("TestUser02"); IBuddyList buddyList = client1.BuddyList; clearBuddyList(client1); buddyList.AddBuddy(account2.Identity); // It takes a while for the buddy to be added in the server // This loop will wait until it happens or we time out DateTime start = DateTime.Now; while (DateTime.Now - start < testTimeout) { if (buddyList.Buddies.Count != 0) { break; } Thread.Sleep(buddyListUpdateSleepTimeSpan); } Assert.AreEqual(1, buddyList.Buddies.Count); Assert.AreEqual(account2.Identity, buddyList.Buddies.First().Identity); }
public void SendMessageTest() { TimeSpan testTimeout = TimeSpan.FromSeconds(30); AutoResetEvent waitHandle = new AutoResetEvent(false); XMPPMessengerClient client1 = getTestClient("TestUser01"); XMPPMessengerClient client2 = getTestClient("TestUser02"); client2.MessageArrived += delegate(object sender, MessageArrivedEventArgs e) { waitHandle.Set(); }; client1.sendMessage(client2.Identity, "Hello"); Assert.IsTrue(waitHandle.WaitOne(testTimeout)); }