public void MessagesGetterTest() { LocalUser user = Login(); var status = MessageGetter.MessageStatus.UnknownError; bool done = false; List <Message> messages = null; List <Conversation> conversations = ConversationGetterCall(); var getter = new MessageGetter(user, (_status, _messages) => { status = _status; messages = _messages; done = true; }); getter.get(conversations[0], 0, false); while (!done) { } Assert.AreEqual(status, MessageGetter.MessageStatus.Success); Assert.AreNotEqual(messages, null); }
public void MessagingFullTest() { LocalUser user = Login(username: "******", password: "******"); var statusGetterConversation = ConversationGetter.GetStatus.UnknownError; var statusStarter = ConversationStarter.ConversationStatus.UnknownError; var statusPoster = MessagePoster.MessageStatus.UnknownError; var statusGetterMessages = MessageGetter.MessageStatus.UnknownError; bool done = false; Conversation conversation = null; string message = null; List <Message> messages = null; List <Conversation> conversations = null; Dictionary <String, User> users = null; var getterConv = new ConversationGetter(user, (_status, _conversations, _users) => { statusGetterConversation = _status; conversations = _conversations; users = _users; done = true; }); var conversationStarter = new ConversationStarter(user, (_status, _conversation, _users) => { statusStarter = _status; conversation = _conversation; users = _users; done = true; }); var messagePoster = new MessagePoster(user, (_status, _conversation, _message) => { statusPoster = _status; conversation = _conversation; message = _message; done = true; }); var messageGetter = new MessageGetter(user, (_status, _messages) => { statusGetterMessages = _status; messages = _messages; done = true; }); ///Pradedam Conversation done = false; conversationStarter.start("test4"); while (!done) { } Assert.AreEqual(statusStarter, ConversationStarter.ConversationStatus.Success); Assert.AreNotEqual(conversation, null); /// ///Gaunam messages done = false; messageGetter.get(conversation, 0, false); while (!done) { } Assert.AreEqual(statusGetterMessages, MessageGetter.MessageStatus.Success); Assert.AreNotEqual(messages, null); var timestamp = (messages.Count == 0 ? 0 : messages[messages.Count - 1].Timestamp); /// ///Siunčiam message var random = new Random(); done = false; messagePoster.post(conversation, random.Next().ToString()); while (!done) { } Assert.AreEqual(statusPoster, MessagePoster.MessageStatus.Success); Assert.AreNotEqual(message, null); /// ///Gaunam messages done = false; messageGetter.get(conversation, timestamp, false); while (!done) { } Assert.AreEqual(statusGetterMessages, MessageGetter.MessageStatus.Success); Assert.AreNotEqual(messages, null); ///Tikrinam ar nusisiuntė var myMessage = messages.Find((_message) => { return(_message.Text == message && _message.Username == user.Username); }); Assert.AreNotEqual(myMessage, null); /// ///Gaunam conversations done = false; getterConv.get(true); while (!done) { } Assert.AreEqual(statusGetterConversation, ConversationGetter.GetStatus.Success); Assert.AreNotEqual(users, null); Assert.AreNotEqual(conversations, null); var myConversation = conversations.Find((_conversation) => { return(_conversation.Id == conversation.Id); }); Assert.AreNotEqual(myConversation, null); /// }