public void FetchMessageSucceds()
        {
            #region Setup for test
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            List<MessagePing> returnValue;
            Expression<Func<MessagePing, bool>> expr = d => d.Destination == defaultDestination;
            repoInstance.Setup(ent => ent.Add(It.IsAny<MessagePing>())).Returns(dummyMessage);
            #endregion

            #region Test
            returnValue = testSubject.FetchMessages(defaultSource, defaultDestination);
            //repoInstance.Verify(e => e.Where(
            //                                    It.Is<Expression<Func<MessagePing, bool>>>(
            //                                        param => Expression.Lambda<Func<string>>(
            //                                            (MemberExpression)(param.Body as BinaryExpression).Right
            //                                        ).Compile()() == "+919840200524")
            //                                    )
            //                                );
            //repoInstance.Verify(e => e.Where(
            //                                    It.Is<Expression<Func<MessagePing, bool>>>(
            //                                        param => Expression.Lambda<Func<string>>(
            //                                            (MemberExpression)(param.Body as BinaryExpression).Left
            //                                        ).Body.ToString() == "d.Destination")
            //                                    )
            //                                );
            //Assert.IsNotNull(returnValue);
            Assert.IsTrue(0 < returnValue.Count);
            MessagePing retrievedMessage = returnValue[0];
            Assert.IsTrue(dummyMessage.Id == retrievedMessage.Id);
            #endregion
        }
示例#2
0
        public void MessagesAreFetchedWithProperProfileDetails()
        {
            #region Test Setup
            List<MessagePing> callResult;
            List<string> profilePictures;
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            #endregion

            #region Test Operations
            callResult = testSubject.FetchMessages(DEFAULT_SOURCE, DEFAULT_DESTINATION);
            profilePictures = callResult.Select<MessagePing, string>(r => r.DestinedUserProfile.PingerImage).ToList<string>();
            #endregion

            #region Assert Operation Result
            CollectionAssert.AllItemsAreNotNull(profilePictures);
            #endregion
        }
示例#3
0
        public void ListMessagesSucceeds()
        {
            #region Test Setup
            List<MessagePing> callResult;
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            #endregion

            #region Test Operations
            callResult = testSubject.FetchMessages(DEFAULT_SOURCE, DEFAULT_DESTINATION);
            #endregion

            #region Assert Operation Result
            CollectionAssert.AllItemsAreNotNull(callResult);
            #endregion
        }
示例#4
0
        public void MessagesAreFetchedWithProfileDetails()
        {
            #region Test Setup
            List<MessagePing> callResult;
            bool valueCheckForAllItems = true;
            testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
            #endregion

            #region Test Operations
            callResult = testSubject.FetchMessages(DEFAULT_SOURCE, DEFAULT_DESTINATION);
            foreach (MessagePing message in callResult)
            {
                valueCheckForAllItems &= null != message.DestinedUserProfile;
            }
            #endregion

            #region Assert Operation Result
            Assert.IsTrue(valueCheckForAllItems);
            #endregion
        }
 public void CheckConversationOrder()
 {
     testSubject = new WorkerProcess(repoInstance.Object, membershipInstance.Object, profileInstance.Object);
     string source = "+919941841903";
     string destination = "+919840200524";
     List<MessagePing> conversation = testSubject.FetchMessages(source, destination);
     for (int i = 1; i < conversation.Count - 1; i++)
     {
         Assert.IsTrue(conversation[i].MessageSentUTC > conversation[i - 1].MessageSentUTC,
                     "The test failed for " + i + " iteration");
     }
 }