public void DeleteMessage_ShouldReturnAMessage()
        {
            //Arrange
            Message returnMessage = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                var conversation            = msService.CreateConversation(testAuthUserId, testContactUserId, testContactUsername);
                db.SaveChanges();
                Message message = new Message
                {
                    ConversationOfMessage = conversation,
                    OutgoingMessage       = true,
                    MessageContent        = "testContent2",
                    CreatedDate           = DateTime.Now
                };

                message = msService.SaveMessageToDatabase(message);
                db.SaveChanges();
                var foundMessage = db.Messages.Where(m => m.MessageContent.Equals("testContent2")).FirstOrDefault();
                returnMessage = msService.DeleteMessage(foundMessage.Id);
                db.SaveChanges();


                //Assert
                Assert.NotNull(returnMessage);
            }
        }
        public void GetRecentMessageFromConversation_ShouldReturnAMessage()
        {
            //Arrange
            Message expected = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                var conversation            = msService.CreateConversation(testAuthUserId, testContactUserId, testContactUsername);
                db.SaveChanges();
                var message = new Message
                {
                    ConversationOfMessage = conversation,
                    OutgoingMessage       = true,
                    MessageContent        = "testContent2",
                    CreatedDate           = DateTime.Now
                };

                message = msService.SaveMessageToDatabase(message);
                db.SaveChanges();
                var foundConversation = db.Conversations.Where(c => c.UserId == testAuthUserId && c.ContactUserId == testContactUserId).FirstOrDefault();

                expected = msService.GetMostRecentMessageConversation(foundConversation.Id);
            }

            //Assert
            Assert.NotNull(expected);
        }
        public void GetAllConversation_ShouldReturnACollectionOfConversation()
        {
            //Arrange
            IEnumerable <Conversation> conversations = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                msService.CreateConversation(testAuthUserId, testContactUserId, testContactUsername);
                db.SaveChanges();
                conversations = msService.GetAllConversation(testAuthUserId);
            }

            //Assert
            Assert.NotNull(conversations);
        }
        public void GetaConversationById_ShouldReturnAConversation()
        {
            //Arrange
            Conversation conversation = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                var returnConversation      = msService.CreateConversation(testAuthUserId, testContactUserId, testContactUsername);
                db.SaveChanges();
                conversation = msService.GetConversationFromId(returnConversation.Id);
            }

            //Assert
            Assert.NotNull(conversation);
        }
Example #5
0
        public void GetAllConversations_ShouldReturnListOfConversation()
        {
            //Arrange
            List <Conversation> conversations = null;

            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                msService.CreateConversation(testAuthUserId, testContactUserId, "*****@*****.**");
                db.SaveChanges();
            }

            //Act

            MessengerManager messengerManager = new MessengerManager();

            conversations = messengerManager.GetAllConversations(testAuthUserId).ToList();
            //Assert
            Assert.NotEmpty(conversations);
        }
Example #6
0
        public void GetConversationFromId_ShouldReturnConversation()
        {
            //Arrange
            Conversation conversation = null;
            Conversation expected     = null;

            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                conversation = msService.CreateConversation(testAuthUserId, testContactUserId, "*****@*****.**");
                db.SaveChanges();
            }

            //Act
            MessengerManager messengerManager = new MessengerManager();

            expected = messengerManager.GetConversationFromId(conversation.Id);

            //Assert
            Assert.NotNull(expected);
        }
Example #7
0
        public void DeleteConversation_FindDeletedConversationShouldReturnNull()
        {
            //Arrange
            Conversation conversation      = null;
            Conversation foundConversation = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                conversation = msService.CreateConversation(testAuthUserId, testContactUserId, "*****@*****.**");
                db.SaveChanges();

                MessengerManager messengerManager = new MessengerManager();
                conversation = messengerManager.DeleteConversation(conversation.Id);


                foundConversation = db.Conversations.Where(c => c.Id == conversation.Id).FirstOrDefault();
            }

            //Assert
            Assert.Null(foundConversation);
        }
        public void DeleteConversation_ShouldReturnAConversation()
        {
            //Arrange

            Conversation conversation      = null;
            Conversation foundConversation = null;

            //Act
            using (var db = new DatabaseContext())
            {
                MessengerServices msService = new MessengerServices(db);
                conversation = msService.CreateConversation(testAuthUserId, testContactUserId, testContactUsername);
                db.SaveChanges();


                conversation = msService.DeleteConversation(conversation.Id);
                db.SaveChanges();

                foundConversation = db.Conversations.Where(c => c.Id == conversation.Id).FirstOrDefault();
            }

            //Assert
            Assert.Null(foundConversation);
        }