Example #1
0
 /// <summary>
 /// Initialize DAO
 /// </summary>
 /// <param name="connexionString">Connection chain</param>
 public static void DAOInitialize(string connexionString)
 {
     _objDaoLogin = DAOLogin.getInstance();
     _objDaoLogin.ConnectionString = connexionString;
     _objDaoTopic = DAOTopic.getInstance();
     _objDaoTopic.ConnectionString = connexionString;
     _objDaoRubric = DAORubric.getInstance();
     _objDaoRubric.ConnectionString = connexionString;
     _objDaoTopicReply = DAOTopicReply.getInstance();
     _objDaoTopicReply.ConnectionString = connexionString;
 }
        public void Test_AddNewTopicReply()
        {
            //Arrange
            Controller.DAOInitialize("Data Source=176.31.248.137;Initial Catalog=user19;Persist Security Info=True;User ID=user19;Password=274user19");

            DAOTopicReply objDaoTopicReply = DAOTopicReply.getInstance();
            Message       messageExpected  = new Message();

            messageExpected.ReplyContent    = "UnitTest TopicReply";
            messageExpected.DateAdd         = DateTime.Now;
            messageExpected.DateUp          = DateTime.Now;
            messageExpected.Topic.TopicId   = 1;
            messageExpected.Person.PersonId = 1;

            // Act
            objDaoTopicReply.AddNewTopicReply(messageExpected);
            Message messageActual = new Message();
            string  command       = "SELECT * FROM TOPICREPLY WHERE REPLYCONTENT='UnitTest TopicReply'";

            using (SqlConnection connection = new SqlConnection("Data Source=176.31.248.137;Initial Catalog=user19;Persist Security Info=True;User ID=user19;Password=274user19"))
            {
                SqlCommand cmd = new SqlCommand(command, connection);
                connection.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    messageActual.ReplyContent  = reader.GetString(1);
                    messageActual.DateAdd       = reader.GetDateTime(2);
                    messageActual.DateUp        = reader.GetDateTime(3);
                    messageActual.Topic.TopicId = reader.GetInt32(4);
                }
                connection.Close();
                messageActual.Person.PersonId = 1;
            }

            // Assert
            Assert.IsTrue(messageExpected.Equals(messageActual));
        }
Example #3
0
 /// <summary>
 /// Uses the method of retrieving the last ten messages in db
 /// </summary>
 /// <param name="topicId">topic id</param>
 /// <returns>message list</returns>
 public static List <Message> GetTopicReplyTop10(int topicId)
 {
     _objDaoTopicReply = DAOTopicReply.getInstance();
     return(_objDaoTopicReply.GetTopicReplyTop10(topicId));
 }
Example #4
0
 /// <summary>
 /// Uses the voting verification method of a topic in db
 /// </summary>
 /// <param name="topicReplyId">message id</param>
 /// <param name="personId">person id</param>
 /// <returns>true if the person has already voted</returns>
 public static bool CheckVoted(int topicReplyId, int personId)
 {
     _objDaoTopicReply = DAOTopicReply.getInstance();
     return(_objDaoTopicReply.CheckVoted(topicReplyId, personId));
 }
Example #5
0
 /// <summary>
 /// Uses the voting method of a topic in db
 /// </summary>
 /// <param name="topicReplyId">message id</param>
 /// <param name="personId">person id</param>
 public static void UpdateVoteTopicReply(int topicReplyId, int personId)
 {
     _objDaoTopicReply = DAOTopicReply.getInstance();
     _objDaoTopicReply.UpdateVoteTopicReply(topicReplyId, personId);
 }
Example #6
0
 /// <summary>
 /// Uses the method of adding a message in db
 /// </summary>
 /// <param name="message">message</param>
 public static void AddNewTopicReply(Message message)
 {
     _objDaoTopicReply = DAOTopicReply.getInstance();
     _objDaoTopicReply.AddNewTopicReply(message);
 }
Example #7
0
 /// <summary>
 /// Uses the method of deleting a message in db
 /// </summary>
 /// <param name="personId">person id</param>
 /// <param name="topicReplyId">message id</param>
 public static void DeleteTopicReplyById(int personId, int topicReplyId)
 {
     _objDaoTopicReply = DAOTopicReply.getInstance();
     _objDaoTopicReply.DeleteTopicReplyById(personId, topicReplyId);
 }