Пример #1
0
 private static void Info(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsInfoEnabled)
     {
         log.Info(getMsg(), ex);
     }
 }
Пример #2
0
 private static void Trace(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsTraceEnabled)
     {
         log.Trace(getMsg(), ex);
     }
 }
Пример #3
0
 private static void Debug(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(getMsg(), ex);
     }
 }
Пример #4
0
 private static void Error(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsErrorEnabled)
     {
         log.Error(getMsg(), ex);
     }
 }
Пример #5
0
 private static void Fatal(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsFatalEnabled)
     {
         log.Fatal(getMsg(), ex);
     }
 }
Пример #6
0
 private static void Warn(ILog log, MessageGetter getMsg, Exception ex)
 {
     if (log.IsWarnEnabled)
     {
         log.Warn(getMsg(), ex);
     }
 }
Пример #7
0
        public StEvalDeviceView(StEvalPeriph periph)
        {
            stEvalPeriph = periph;

            stEvalPeriph.OnMessageReceived += NewMessage;
            MessageGetter getterName = new MessageGetter(MessageId.WhoIAm);

            stEvalPeriph.Send(getterName);
        }
Пример #8
0
        public StEvalScannerView(List <StEvalPeriph> stEvalPeriphs)
        {
            nameDictionnary = new Dictionary <string, StEvalPeriph>();

            MessageGetter getterName = new MessageGetter(MessageId.WhoIAm);

            stEvalPeriphs.ForEach(p =>
            {
                p.OnMessageReceived += NewMessage;
                p.Send(getterName);
            });
        }
Пример #9
0
        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);
        }
Пример #10
0
        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);
            ///
        }
Пример #11
0
        public void GetTtf()
        {
            MessageGetter message = new MessageGetter(MessageId.Ttf);

            stEvalPeriph.Send(message);
        }
Пример #12
0
        public void GetWhoIAm()
        {
            MessageGetter message = new MessageGetter(MessageId.WhoIAm);

            stEvalPeriph.Send(message);
        }