コード例 #1
0
        public void CanGetUserMessages()
        {
            var mockClass   = new MessageSend();
            var testClass   = new MessageGet();
            var testMessage = new MessageModel
            {
                DateTime = DateTime.Now.ToString(),
                Message  = "Hello World!",
                UserFrom = "Jack Black"
            };

            var secondTestMessage = new MessageModel
            {
                DateTime = DateTime.Now.ToString(),
                Message  = "Hello World!",
                UserFrom = "Jack Pink"
            };

            mockClass.SendMessages(testMessage);
            mockClass.SendMessages(secondTestMessage);
            List <MessageModel> List = testClass.GetMessages();


            Assert.AreEqual(List.First().Message, testMessage.Message);
            Assert.AreEqual(List.First().UserFrom, testMessage.UserFrom);
        }
コード例 #2
0
        public void TheMessageIsSentToTheDatabase()
        {
            var testModel = new MessageModel
            {
                DateTime = DateTime.Now.ToString(),
                Message  = "Bye World!",
                UserTo   = "Jack Smack"
            };
            var testClass = new MessageSend();

            Assert.AreEqual(testClass.SendMessages(testModel), true);
        }
コード例 #3
0
        public void CanGetMessagesFromTheDatabase()
        {
            var mockClass   = new MessageSend();
            var testClass   = new MessageGet();
            var testMessage = new MessageModel
            {
                DateTime = DateTime.Now.ToString(),
                Message  = "Hello World!",
                UserTo   = "Jack Black"
            };

            mockClass.SendMessages(testMessage);
            List <MessageModel> List = testClass.GetMessages();

            foreach (var item in List)
            {
                Assert.AreEqual(item.Message, testMessage.Message);
                Assert.AreEqual(item.UserTo, testMessage.UserTo);
            }
        }