Ejemplo n.º 1
0
        public static int AddMessage(ChatMessage model)
        {
            using (MySqlDbConnection con = MySqlDbConnection.Connect())
            {
                con.CommandText = "insert into chatmessage (Mid, UserId, Message, CreateDate) values (@Mid, @UserId, @Message, @CreateDate)";
                con.AddParameters("Mid", model.Mid);
                con.AddParameters("UserId", model.UserId);
                con.AddParameters("Message", model.Message);
                con.AddParameters("CreateDate", model.CreateDate);

                return con.Exec();
            }
        }
        public void DisconnectTest()
        {
            DbConnection dbConnection = new MySqlDbConnection(MockData.LHost, MockData.LPort, MockData.LDb, MockData.LUser, MockData.LPass);

            dbConnection.Connect();

            Assert.IsTrue(dbConnection.IsAlive);
            Assert.AreEqual(System.Data.ConnectionState.Open, dbConnection.MyCurrentState);

            dbConnection.Disconnect();
            Assert.IsFalse(dbConnection.IsAlive);
            Assert.AreEqual(System.Data.ConnectionState.Closed, dbConnection.MyCurrentState);
        }