示例#1
0
 public void FullCoreTest_SendMessage()
 {
     var mockServer = new Mock<IServerMock>();
     var commLayer = new CommLayer(mockServer.Object);
     var commHandler = new CommHandler(commLayer);
     Core c = new Core(commHandler);
     ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message");
     mockServer.Raise(m => m.MessageSent += null, new ChatEventArgs(msg));
     Queue<ChatMessage> msgList = c.GetMessageQueue();
     ChatMessage msgResult = msgList.Dequeue();
     Assert.AreEqual(msgResult.Speaker, msg.Speaker);
     Assert.AreEqual(msgResult.Timestamp, msg.Timestamp);
     Assert.AreEqual(msgResult.Text, msg.Text);
 }
示例#2
0
文件: CoreTest.cs 项目: wrusse3/gswat
        public void CoreTest_Constructor_ValidParams()
        {
            // Create objects
            var mockHandler = new Mock<ICommHandler>();
            Core c = new Core(mockHandler.Object);

            // Raise MessageSent event in CommHandler
            ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message");
            mockHandler.Raise(m => m.CoreListener += null, new ChatEventArgs(msg));

            // Retrieve message queue and check for message
            Queue<ChatMessage> msgList = c.GetMessageQueue();
            ChatMessage msgResult = msgList.Dequeue();
            Assert.AreEqual(msgResult.Speaker, msg.Speaker);
            Assert.AreEqual(msgResult.Timestamp, msg.Timestamp);
            Assert.AreEqual(msgResult.Text, msg.Text);
        }
示例#3
0
文件: CoreTest.cs 项目: wrusse3/gswat
        public void CoreTest_Constructor_NullParams()
        {
            // Create objects
            var mockHandler = new Mock<ICommHandler>();
            Core c = new Core(null);

            // Raise MessageSent event in CommHandler
            ChatMessage msg = new ChatMessage(new DateTime(2012, 12, 18), "Llamautomatic", "This is a test message");
            mockHandler.Raise(m => m.CoreListener += null, new ChatEventArgs(msg));

            // Retrieve message queue and check for empty queue
            Queue<ChatMessage> msgList = c.GetMessageQueue();
            Assert.AreEqual(msgList.Count, 0);

            // Check for empty CommHandler reference in Core
            Assert.AreEqual(c.CommHandler, null);
        }